Req #76923 [Com]: null comparing to string '0'
| From: | spam2 at rhsoft dot net | Date: | Sun, 23 Sep 2018 16:33:32 +0000 |
| Subject: | Req #76923 [Com]: null comparing to string '0' | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-217209@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76923&edit=1
ID: 76923
Comment by: spam2 at rhsoft dot net
Reported by: gegpcoder at gmail dot com
Summary: null comparing to string '0'
Status: Open
Type: Feature/Change Request
Package: *General Issues
Operating System: all
PHP Version: 7.3.0RC1
Block user comment: N
Private report: N
New Comment:
what at http://www.php.net/en/language.types.null 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
Previous Comments:
------------------------------------------------------------------------
[2018-09-23 16:09:22] gegpcoder at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/language.types.null
---
if '0' is false when converted to boolean and null is false as well
why
0==null is true
false==null is true
'' ==null is true
array()==null is true
but '0' == null is false
Test script:
---------------
<?php
echo null == 0; //true
echo null == array(); //true
echo null == ''; //true
echo null == '0'; //false
?>
Expected result:
----------------
1111
Actual result:
--------------
111
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76923&edit=1