Bug #75484 [Com]: comparation of int and string
| From: | spam2 at rhsoft dot net | Date: | Fri, 03 Nov 2017 16:18:47 +0000 |
| Subject: | Bug #75484 [Com]: comparation of int and string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-212439@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75484&edit=1
ID: 75484
Comment by: spam2 at rhsoft dot net
Reported by: burhan at wflux dot pro
Summary: comparation of int and string
Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: ubuntu
PHP Version: 7.1.11
Block user comment: N
Private report: N
New Comment:
if( $a != $b ) is plain wrong
if( $a !== $b ) would work
Previous Comments:
------------------------------------------------------------------------
[2017-11-03 16:16:07] requinix@php.net
http://php.net/manual/en/language.types.type-juggling.php
http://php.net/manual/en/types.comparisons.php
------------------------------------------------------------------------
[2017-11-03 16:08:23] 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'
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75484&edit=1