php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75484 comparation of int and string
Submitted: 2017-11-03 16:08 UTC Modified: 2017-11-03 16:16 UTC
From: burhan at wflux dot pro Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 7.1.11 OS: ubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: burhan at wflux dot pro
New email:
PHP Version: OS:

 

 [2017-11-03 16:08 UTC] burhan at wflux dot pro
Description:
------------
bug on comparation betwen integer and string parset from same variable.

Test script:
---------------
//Enter your code here, enjoy!
$COMPANY ="942clud_clinic";

$a = ((int)$COMPANY);
$b = (string)$COMPANY;

echo gettype($a);
echo "\n";
echo $a;
echo "\n";
echo gettype($b);
echo "\n";
echo $b;
echo "\n";

if( $a != $b ){
    echo 'aaaa';
}
else {
    echo 'bbbb';
}

Expected result:
----------------
'aaaa'

Actual result:
--------------
'bbbb'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-11-03 16:16 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2017-11-03 16:18 UTC] spam2 at rhsoft dot net
if( $a != $b ) is plain wrong
if( $a !== $b ) would work
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 18:01:34 2024 UTC