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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

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: Sun May 05 16:01:30 2024 UTC