From:             bobwei9 at hotmail dot com
Operating system: Irrelevant (OS X 10.8)
PHP version:      master-Git-2013-01-12 (Git)
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:Strange behaviour with precedence order

Description:
------------
I think the test script should be self explaining.

Order is somewhat strange.

Once it seems to be evaluated as

$first = (+$i); // => 0
$second = ($i += 3); // => 3
$result = $first + $second; // => 3

and once as:

$second = ($i += 3); // => 3
$first = ($i); // => 3
$result = $first + $second; // => 6

Test script:
---------------
php > $i = 0; print (+ $i + ($i += 3))."\n";
3
php > $i = 0; print ($i + ($i += 3))."\n";
6

Expected result:
----------------
I'd expect that the parenthesis are only resolved if encountered and not
first resolved, then the variable replaced by its value.


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

Reply via email to