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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: david dot phpnet at gazolinemm dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 17:01:30 2025 UTC