功能无法正常运行? (坦克验证)
之间存在差异
function foo($a){$blah = $a}.......
foo($CONSTANT);
有人可以解释一下为什么和
function foo() { $blah = $CONSTANT}.......
foo();
顶级方法对我有用,而另一种则不然。 具体来说,下面的语句发现 if 语句为假:
$this->setsession($user->id,$user->email, ($user->activated == 1) ? STATUS_ACTIVATED : STATUS_NOT_ACTIVATED);
if ($user->activated == 0) { // fail - not activated
$this->error = array('not_activated' => '');
而这个语句发现它为 true:
$this->setsession();
if ($user->activated == 0) { // fail - not activated
$this->error = array('not_activated' => '');
Could someone please explain why there is a difference between
function foo($a){$blah = $a}.......
foo($CONSTANT);
and
function foo() { $blah = $CONSTANT}.......
foo();
The top method is working for me, the other is not.
Specifically the below finds the if statement false:
$this->setsession($user->id,$user->email, ($user->activated == 1) ? STATUS_ACTIVATED : STATUS_NOT_ACTIVATED);
if ($user->activated == 0) { // fail - not activated
$this->error = array('not_activated' => '');
While this one finds it true:
$this->setsession();
if ($user->activated == 0) { // fail - not activated
$this->error = array('not_activated' => '');
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抱歉,问题写得不好。
区别在于变量作用域,我需要传递变量,因为我调用的变量无法被引用。
Sorry for a poorly written question.
The difference is variable scope, I need to pass the variables because the ones I was calling were not able to be referenced.