ID:               35870
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jevon at jevon dot org
-Status:           Open
+Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: Windows XP
 PHP Version:      5.1.1
 New Comment:

Please read again how ternary operator works. 
hint1: isset($x[1]) == false
hint2: when condition in ternary operation evaluates to false, the
stuff after : is executed..


Previous Comments:
------------------------------------------------------------------------

[2006-01-02 05:56:26] jevon at jevon dot org

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 this bug report at http://bugs.php.net/?id=35870&edit=1

Reply via email to