|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #76923 null comparing to string '0'
Submitted: 2018-09-23 16:09 UTC Modified: 2018-09-23 18:03 UTC
From: gegpcoder at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.3.0RC1 OS: all
Private report: No CVE-ID: None
 [2018-09-23 16:09 UTC] gegpcoder at gmail dot com
From manual page:

if '0' is false when converted to boolean and null is false as well
0==null is true
false==null is true
'' ==null is true 
array()==null is true

but '0' == null is false 

Test script:
echo null == 0; //true
echo null == array(); //true
echo null == ''; //true
echo null == '0'; //false

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-09-23 16:33 UTC] spam2 at rhsoft dot net
what at akes you believe '0' shou,d be the same as NULL?

'0' is NOT an empty string, it's a string which just the char 0 in it
so when '0' is not empty why should it be the same as NULL
 [2018-09-23 18:03 UTC]
-Status: Open +Status: Not a bug
 [2018-09-23 18:03 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

It's far too late to change this behavior.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Apr 18 06:01:23 2021 UTC