From: pasamio at gmail dot com Operating system: Linux 2.6.5-7.191-smp PHP version: 5.2.6 PHP Bug Type: Scripting Engine problem Bug description: Addition and minus operators do not work properly when appended to a string
Description: ------------ When using a simple addition or minus operator that is prepended by a string and concatenated to it will fail to work properly if the string has a value. When the string is empty (e.g. '' or ' ') it will work properly. The multiplication and division functions operate appropriately. Reproduce code: --------------- <?php $x = 10; $i = 2; echo "Addition Test\n"; echo 'Test 1: '. $x + $i . "\n"; echo 'Test 2: '. ($x + $i) . "\n"; echo 'Test 3: '; echo $x + $i . "\n"; echo 'Test 4: '; echo ''. $x + $i ."\n"; echo "\n"; echo "Subtraction Test\n"; echo 'Test 1: '. $x - $i . "\n"; echo 'Test 2: '. ($x - $i) . "\n"; echo 'Test 3: '; echo $x - $i . "\n"; echo 'Test 4: '; echo 'x'. $x - $i ."\n"; echo "\n"; Expected result: ---------------- [EMAIL PROTECTED]:~/public_html/testing> php bug-minus.php Addition Test Test 1: 12 Test 2: 12 Test 3: 12 Test 4: 12 Subtraction Test Test 1: 8 Test 2: 8 Test 3: 8 Test 4: 8 Actual result: -------------- [EMAIL PROTECTED]:~/public_html/testing> php bug-minus.php Addition Test 2 Test 2: 12 Test 3: 12 Test 4: 12 Subtraction Test -2 Test 2: 8 Test 3: 8 Test 4: 8 -- Edit bug report at http://bugs.php.net/?id=45716&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45716&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45716&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45716&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45716&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45716&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45716&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45716&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45716&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45716&r=support Expected behavior: http://bugs.php.net/fix.php?id=45716&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45716&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45716&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45716&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45716&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45716&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45716&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45716&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45716&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45716&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45716&r=mysqlcfg