Bug #51546 [NEW]: If shorthand statement
| From: | michaelozeryansky at hotmail dot com | Date: | Tue, 13 Apr 2010 02:23:53 +0000 |
| Subject: | Bug #51546 [NEW]: If shorthand statement | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-149527@lists.php.net to get a copy of this message | ||
From:
Operating system: Linux
PHP version: 5.2.13
Package: *General Issues
Bug Type: Bug
Bug description:If shorthand statement
Description:
------------
When I use nested shorthand if statements the result doesn't seem to follow
what I expected. I am not sure if this is a bug, but the results are
different in other languages.
Test script:
---------------
<?php
var_dump ((true) ?"a":(true) ?"b":"c") ; // b
var_dump ((true) ?"a":(false)?"b":"c") ; // b
var_dump ((false)?"a":(true) ?"b":"c") ; // b
var_dump ((false)?"a":(false)?"b":"c") ; // c
?>
I wrote a c++ script to see what the results should be in another language
cout << ((true) ?"a":(true) ?"b":"c") << endl; // result =
a
cout << ((true) ?"a":(false)?"b":"c") << endl; // result =
a
cout << ((false)?"a":(true) ?"b":"c") << endl; // result =
b
cout << ((false)?"a":(false)?"b":"c") << endl; // result =
c
Expected result:
----------------
The PHP script should print out:
a
a
b
c
Actual result:
--------------
In the comments behind each line
--
Edit bug report at http://bugs.php.net/bug.php?id=51546&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51546&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51546&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51546&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=51546&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51546&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=51546&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=51546&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=51546&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=51546&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=51546&r=support
Expected behavior: http://bugs.php.net/fix.php?id=51546&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=51546&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=51546&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=51546&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51546&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=51546&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=51546&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=51546&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=51546&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=51546&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=51546&r=mysqlcfg