Bug #17180: Operator Precedence
| From: | sitnikov at infonet dot ee | Date: | Mon, 13 May 2002 13:36:32 +0000 |
| Subject: | Bug #17180: Operator Precedence | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-7527@lists.php.net to get a copy of this message | ||
From: sitnikov@infonet.ee
Operating system:
PHP version: 4.2.0
PHP Bug Type: Scripting Engine problem
Bug description: Operator Precedence
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 bug report at http://bugs.php.net/?id=17180&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=17180&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=17180&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=17180&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=17180&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17180&r=support
Expected behavior: http://bugs.php.net/fix.php?id=17180&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=17180&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=17180&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=17180&r=globals