Req #76923 [Opn->Nab]: null comparing to string '0'
| From: | requinix@php.net | Date: | Sun, 23 Sep 2018 18:03:10 +0000 |
| Subject: | Req #76923 [Opn->Nab]: null comparing to string '0' | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-217212@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
Updated by: requinix@php.net
Reported by: gegpcoder at gmail dot com
Summary: null comparing to string '0'
-Status: Open
+Status: Not a bug
Type: Feature/Change Request
Package: *General Issues
Operating System: all
PHP Version: 7.3.0RC1
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
http://php.net/manual/en/language.types.type-juggling.php
http://php.net/manual/en/types.comparisons.php
It's far too late to change this behavior.
Previous Comments:
------------------------------------------------------------------------
[2018-09-23 16:33:32] spam2 at rhsoft dot net
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
------------------------------------------------------------------------
[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