Bug #63825 [Opn->Csd]: php dose not follow the operator precedence

2012-12-20 Thread rssidea at qq dot com
Edit report at https://bugs.php.net/bug.php?id=63825&edit=1

 ID: 63825
 User updated by:rssidea at qq dot com
 Reported by:rssidea at qq dot com
 Summary:php dose not follow the operator precedence
-Status: Open
+Status: Closed
 Type:   Bug
 Package:*Compile Issues
 Operating System:   all
 PHP Version:5.3.20
 Block user comment: N
 Private report: N

 New Comment:

I find a note in documentation:Although = has a lower precedence than most 
other 
operators, PHP will still allow expressions similar to the following: if (!$a = 
foo()), in which case the return value of foo() is put into $a.

so, this is not a bug, but it may be a snare :)


Previous Comments:

[2012-12-21 06:10:55] rssidea at qq dot com

Description:

By Operator Precedence on 
http://php.net/manual/en/language.operators.precedence.php, logical operator 
'||' 
is higher than assignment operator '=', so the script below should cause a 
syntax 
error. 

Test script:
---
$a = $b = 0;
if ($a = 1 || $b = 1) {
echo $a;
}


Expected result:

execute as:
if ($a = (1 || $b) = 1) {

output:
syntax error, unexpected '='

Actual result:
--
execute as:
if ($a = (1 || ($b = 1))) {

output:
1






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63825&edit=1


[PHP-BUG] Bug #63825 [NEW]: php dose not follow the operator precedence

2012-12-20 Thread rssidea at qq dot com
From: rssidea at qq dot com
Operating system: all
PHP version:  5.3.20
Package:  *Compile Issues
Bug Type: Bug
Bug description:php dose not follow the operator precedence

Description:

By Operator Precedence on 
http://php.net/manual/en/language.operators.precedence.php, logical
operator '||' 
is higher than assignment operator '=', so the script below should cause a
syntax 
error. 

Test script:
---
$a = $b = 0;
if ($a = 1 || $b = 1) {
echo $a;
}


Expected result:

execute as:
if ($a = (1 || $b) = 1) {

output:
syntax error, unexpected '='

Actual result:
--
execute as:
if ($a = (1 || ($b = 1))) {

output:
1

-- 
Edit bug report at https://bugs.php.net/bug.php?id=63825&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63825&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63825&r=trysnapshot53
Try a snapshot (trunk): 
https://bugs.php.net/fix.php?id=63825&r=trysnapshottrunk
Fixed in SVN:   https://bugs.php.net/fix.php?id=63825&r=fixed
Fixed in release:   https://bugs.php.net/fix.php?id=63825&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63825&r=needtrace
Need Reproduce Script:  https://bugs.php.net/fix.php?id=63825&r=needscript
Try newer version:  https://bugs.php.net/fix.php?id=63825&r=oldversion
Not developer issue:https://bugs.php.net/fix.php?id=63825&r=support
Expected behavior:  https://bugs.php.net/fix.php?id=63825&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=63825&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=63825&r=submittedtwice
register_globals:   https://bugs.php.net/fix.php?id=63825&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63825&r=php4
Daylight Savings:   https://bugs.php.net/fix.php?id=63825&r=dst
IIS Stability:  https://bugs.php.net/fix.php?id=63825&r=isapi
Install GNU Sed:https://bugs.php.net/fix.php?id=63825&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63825&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63825&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63825&r=mysqlcfg