|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63825 php dose not follow the operator precedence
Submitted: 2012-12-21 06:10 UTC Modified: 2012-12-21 11:07 UTC
From: rssidea at qq dot com Assigned:
Status: Not a bug Package: *Compile Issues
PHP Version: 5.3.20 OS: all
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: rssidea at qq dot com
New email:
PHP Version: OS:


 [2012-12-21 06:10 UTC] rssidea at qq dot com
By Operator Precedence on, logical operator '||' 
is higher than assignment operator '=', so the script below should cause a syntax 

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

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

syntax error, unexpected '='

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



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-12-21 06:30 UTC] rssidea at qq dot com
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 :)
 [2012-12-21 06:30 UTC] rssidea at qq dot com
-Status: Open +Status: Closed
 [2012-12-21 11:07 UTC]
-Status: Closed +Status: Not a bug
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Sep 23 04:01:25 2020 UTC