php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14096 strange behavior with NULL value
Submitted: 2001-11-17 19:47 UTC Modified: 2001-11-17 19:50 UTC
From: david dot phpnet at gazolinemm dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.0.6 OS: win2k
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
37 - 2 = ?
Subscribe to this entry?

 
 [2001-11-17 19:47 UTC] david dot phpnet at gazolinemm dot 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-17 19:50 UTC] derick@php.net
It's perfectly normal. The "" gets converted to NULL here. Use === to check for both contents and type.

Derick
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 22:01:31 2024 UTC