php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50330 ("" == NULL) == TRUE ?! (and all other "empty" values)
Submitted: 2009-11-30 10:23 UTC Modified: 2009-12-01 06:41 UTC
From: wdolek at gmail dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.11 OS: GNU/Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: wdolek at gmail dot com
New email:
PHP Version: OS:

 

 [2009-11-30 10:23 UTC] wdolek at gmail dot com
Description:
------------
when comparing empty string, empty array, FALSE, integer 0 with NULL, comparison always returns TRUE. but imho empty string, FALSE or 0 are still any values, instead of NULL is "no" value.
of course, i can use === but documentation says "equals" - isn't is little bit confusing to check also type, when NULL has no type?

in whatever programming lanugage, NULL is NULL and not anything else, don't know, why PHP behaves differently

Reproduce code:
---------------
// should be array(), 0, FALSE etc. instead of ''

if ('' == NULL) {
 echo 'hey dummy, empty string should not be NULL!';
} else {
 echo 'yeah, empty string is not NULL at all!';
}

Expected result:
----------------
yeah, empty string is not NULL at all!

Actual result:
--------------
hey dummy, empty string should not be NULL!

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-01 06:41 UTC] philip@php.net
This will never change.

- http://www.php.net/manual/en/types.comparisons.php

It is what it is.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 12 10:01:28 2024 UTC