Bug #70669 [Opn->Nab]: Strings starting with a '+' == 0
| From: | nikic@php.net | Date: | Fri, 09 Oct 2015 19:27:46 +0000 |
| Subject: | Bug #70669 [Opn->Nab]: Strings starting with a '+' == 0 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-196503@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70669&edit=1
ID: 70669
Updated by: nikic@php.net
Reported by: wayne at huntedcow dot com
Summary: Strings starting with a '+' == 0
-Status: Open
+Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: any
PHP Version: 5.6.14
Block user comment: N
Private report: N
New Comment:
This has nothing to do with '+'. In general 0 == "not-numeric-string" always
holds.
Essentially comparison of integer to string works by casting the string to an integer first.
Previous Comments:
------------------------------------------------------------------------
[2015-10-08 13:05:05] wayne at huntedcow dot com
Description:
------------
Any string starting with a '+' character is resolved as 0 for the purposes of an == check.
This resulted in my if ($value == '+TIMESTAMP') coming out true, when $value = 0.
Test script:
---------------
echo (0 == '+' ? 'TRUE' : 'FALSE');
Expected result:
----------------
FALSE
Actual result:
--------------
TRUE
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70669&edit=1