From:             erik at ruigekonijnen dot nl
Operating system: Windows XP
PHP version:      5.3.0
PHP Bug Type:     Variables related
Bug description:  Assigning in an IF statement does not update value for rest 
of IF

Description:
------------
When you assign a new variable directly into an IF statement, it is not 
updated if you try to read from it in the same statement.

The problem can be supressed by adding an extra set of parentheses, but 
I don't think that should be neccesary.

In the example posted below, this would work just fine:

if ( ( $a = 1 ) && $a > 0 ) {

Reproduce code:
---------------
$a = 0;
if ( $a = 1 && $a > 0 ) {
  echo 'ok';
}
else {
  echo 'wait, what?';
}

Expected result:
----------------
ok

Actual result:
--------------
wait, what?

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

Reply via email to