Bug #17180 Updated: Operator Precedence
| From: | manuzhai@php.net | Date: | Mon, 13 May 2002 21:48:55 +0000 |
| Subject: | Bug #17180 Updated: Operator Precedence | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-7562@lists.php.net to get a copy of this message | ||
ID: 17180
Updated by: manuzhai@php.net
Reported By: sitnikov@infonet.ee
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] sitnikov@infonet.ee
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