0

有人可以解释为什么两者之间存在差异

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' => '');

虽然这个发现是真的:

$this->setsession();

                        if ($user->activated == 0) {                            // fail - not activated
                            $this->error = array('not_activated' => '');
4

1 回答 1

0

抱歉,问题写得不好。区别在于变量范围,我需要传递变量,因为我调用的变量无法被引用。

于 2011-05-22T08:34:29.820 回答