ID: 17180 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Open Bug Type: Scripting Engine problem PHP Version: 4.2.0 New Comment:
"if (!$a = foo(FALSE))" --> you're assigning the output of foo(FALSE) to $a "if (!$a == foo(FALSE))" --> you're comparing !$a and foo(FALSE) Previous Comments: ------------------------------------------------------------------------ [2002-05-13 09:36:32] [EMAIL PROTECTED] Why & How this code will work? <? function foo($flag) { return $flag; } $a=TRUE; echo "if (!\$a = foo(FALSE))) is "; if (!$a = foo(FALSE)) echo "true"; else echo "false"; echo "\n"; var_dump($a); echo "\n"; ?> Output: if (!$a = foo(FALSE))) is true bool(false) http://www.php.net/manual/en/language.operators.php "Operator Precedence" `!` has more precedence than `=` And after `!` we must have boolean constant in left side: FALSE = foo() Explain to me pls that I do not understand P.S. in C & Perl (!$a = foo()) is not valid expression ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=17180&edit=1