php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #73815 bug in compare with ==
Submitted: 2016-12-26 11:34 UTC Modified: 2016-12-26 16:37 UTC
From: rebmann at strom-aus-windkraft dot de Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.1.0 OS:
Private report: No CVE-ID: None
 [2016-12-26 11:34 UTC] rebmann at strom-aus-windkraft dot de
Description:
------------
<?
if('gftrcjihzg'==0) { echo 'true'; }
?>
it gives out: true

This is the worst bug i have ever seen in my live !!!!!!!!!!

Test script:
---------------
<?
if('gftrcjihzg'==0) {  echo 'true'; }
?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-26 16:37 UTC] jhdxr@php.net
-Status: Open +Status: Not a bug
 [2016-12-26 16:37 UTC] jhdxr@php.net
see http://php.net/manual/en/types.comparisons.php

you are using loose comparision, and one of the operands is number, so the string will be converted to number, which is 0 in your case. 

try
```
var_dump('abcd' == '0');
var_dump('abcd' === 0);
```
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 02:01:32 2024 UTC