#45760 [Bgs]: Notice: Undefined index "?:" operator

[email protected] ("s dot masugata at digicom dot dnp dot co dot jp")
Newsgroups php.bugs
Message-ID <[email protected]>
 ID:               45760
 User updated by:  s dot masugata at digicom dot dnp dot co dot jp
 Reported By:      s dot masugata at digicom dot dnp dot co dot jp
 Status:           Bogus
 Bug Type:         *General Issues
 Operating System: Linux Debian(etch)
 PHP Version:      5.3CVS-2008-08-08 (snap)
 New Comment:

Hello. :-)
Behavior expected in this case?

<?php

$_GET['user_id'] = '0';
$user_id = $_GET['user_id'] ?: "anonymous";
var_dump( $user_id );

?>

result:
string(9) "anonymous"


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

[2008-08-08 10:54:20] [email protected]

Hello, That behavior is expected. Coming soon it be documented.

Thanks.

------------------------------------------------------------------------

[2008-08-08 09:45:03] s dot masugata at digicom dot dnp dot co dot jp

Description:
------------
When "?:" operator is used, Notice should not be generated. 




Reproduce code:
---------------
<?php

error_reporting( E_ALL );
$user_id = $_GET['user_id'] ?: "anonymous";

echo $user_id.PHP_EOL;

?>



Expected result:
----------------
anonymous

Actual result:
--------------
Notice: Undefined index: user_id in /path/to/to/notice.php on line 4
anonymous



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=45760&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.