Bug #65570 [Opn->Nab]: 0 equals any string
| From: | nikic@php.net | Date: | Wed, 28 Aug 2013 09:18:11 +0000 |
| Subject: | Bug #65570 [Opn->Nab]: 0 equals any string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-181261@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65570&edit=1
ID: 65570
Updated by: nikic@php.net
Reported by: l dot werner at sprengnetter dot de
Summary: 0 equals any string
-Status: Open
+Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: Linux
PHP Version: 5.5.3
Block user comment: N
Private report: N
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
http://php.net/manual/en/language.operators.comparison.php
Previous Comments:
------------------------------------------------------------------------
[2013-08-28 09:15:38] l dot werner at sprengnetter dot de
Description:
------------
When matching any string against 0 with == or != PHP will say they match.
This is in my eyes absolutely wrong because testing against other types will not result in this
behavior.
Test script:
---------------
<?php
echo "null != 'string' -> ";
var_dump(null != 'string');
echo "<br />";
echo "false != 'string' -> ";
var_dump(false != 'string');
echo "<br />";
echo "0 != 'string' -> ";
var_dump(0 != 'string');
echo "<br />";
echo "1 != 'string' -> ";
var_dump(1 != 'string');
Expected result:
----------------
null != 'string' -> bool(true)
false != 'string' -> bool(true)
0 != 'string' -> bool(true)
1 != 'string' -> bool(true)
Actual result:
--------------
null != 'string' -> bool(true)
false != 'string' -> bool(true)
0 != 'string' -> bool(false)
1 != 'string' -> bool(true)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65570&edit=1