Bug #14096 Updated: strange behavior with NULL value

From: Date: Sun, 18 Nov 2001 00:50:37 +0000
Subject: Bug #14096 Updated: strange behavior with NULL value
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-70769@lists.php.net to get a copy of this message
ID: 14096
Updated by: derick
Reported By: david.phpnet@gazolinemm.com
Old Status: Open
Status: Bogus
Bug Type: Unknown/Other Function
Operating System: win2k
PHP Version: 4.0.6
New Comment:

It's perfectly normal. The "" gets converted to NULL here. Use === to check for both
contents and type.

Derick

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

[2001-11-17 19:47:49] david.phpnet@gazolinemm.com

consider the following script:

$a = "";
$b = NULL;

echo $a == $b ? "true" : "false";
/* weird! it does return TRUE */

echo is_null($a) ? "true" : "false"; // returns FALSE
echo is_null($b) ? "true" : "false"; // returns TRUE
echo empty($a) ? "true" : "false"; // returns TRUE
echo empty($b) ? "true" : "false"; // returns TRUE
echo isset($a) ? "true" : "false"; // returns TRUE
echo isset($b) ? "true" : "false"; // returns FALSE

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



Edit this bug report at http://bugs.php.net/?id=14096&edit=1



Thread (2 messages)

« previous php.dev (#70769) next »