php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70669 Strings starting with a '+' == 0
Submitted: 2015-10-08 13:05 UTC Modified: 2015-10-09 19:27 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: wayne at huntedcow dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.6.14 OS: any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: wayne at huntedcow dot com
New email:
PHP Version: OS:

 

 [2015-10-08 13:05 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-10-09 19:27 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2015-10-09 19:27 UTC] nikic@php.net
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.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 05:00:01 2026 UTC