#21490 [Bgs]: isset in an array

From: Date: Tue, 07 Jan 2003 14:06:40 +0000
Subject: #21490 [Bgs]: isset in an array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-29321@lists.php.net to get a copy of this message
ID: 21490 Updated by: nicos@php.net Reported By: mickael.bailly@free.fr Status: Bogus Bug Type: Unknown/Other Function Operating System: Linux PHP Version: 4.3.0 New Comment: Note: $test = ""; sets the variable test to an empty string. So isset() will return TRUE. Since you're passing "$var" and $var is empty, it will be set to an empty string. That explains why it returns TRUE with "$var" and not with only $var. Thank you for your report. Previous Comments: ------------------------------------------------------------------------ [2003-01-07 07:58:45] nicos@php.net Yes it $ddfdfdf is empty, isset will return FALSE. According to the following script : <?php $test = array ('a' => 'coooool','b' => "$tests"); if (isset($test['b']) ) { echo "OK 1! \n"; } $test = array ('a' => 'coooool','b' => $tests); if ( isset($test['b']) ) { echo "OK 2! \n"; } $tests = "lol"; $test = array ('a' => 'coooool','b' => $tests); if ( isset($test['b']) ) { echo "OK 3! \n"; } ?> That returns: OK 1! OK 3! If you set an element of an array to a variable that is empty, isset will definatly return FALSE. Excepted behaviour. ------------------------------------------------------------------------ [2003-01-07 07:53:02] mickael.bailly@free.fr Don't know if it's a bug or a feature... :) $test = array ('a' => 'coooool','b' => $ddfdfdf); if ( isset($test['b']) ) { echo "OOOK ! \n"; } echoes nothing, and $test = array ('a' => 'coooool','b' => "$ddfdfdf"); if ( isset($test['b']) ) { echo "OOOK ! \n"; } echoes OOOK Is this normal ? ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=21490&edit=1

« previous php.bugs (#29321) next »