From:             jevon at jevon dot org
Operating system: Windows XP
PHP version:      5.1.1
PHP Bug Type:     Scripting Engine problem
Bug description:  isset() on ternary operator incorrectly evaluates conditions

Description:
------------
I'm not sure if this has been submitted before, because it's a bit
difficult to search for 'isset' on bugs.php.net.

Basically if you have isset() in a ternary operation (?:), PHP currently
evaluates all items in the operation, whereas it shouldn't. I guess this
is because isset() is a language construct.

Reproduce code:
---------------
<?php
$x = array();
if (isset($x[1]))
        echo $x[1];
else
        echo 0;

echo isset($x[1]) ? 0 : $x[1];
?>

Expected result:
----------------
0
0

Actual result:
--------------
0
PHP Notice: Undefined offset: 1 in test.php on line 8

-- 
Edit bug report at http://bugs.php.net/?id=35870&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=35870&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=35870&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=35870&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=35870&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=35870&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=35870&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=35870&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=35870&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=35870&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=35870&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=35870&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=35870&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=35870&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=35870&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=35870&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=35870&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=35870&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=35870&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=35870&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=35870&r=mysqlcfg

Reply via email to