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
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: 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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 11:02:27 2025 UTC