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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
43 - 4 = ?
Subscribe to this entry?

 
 [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: Fri May 03 23:01:30 2024 UTC