PHP 4.0 Bug #10234: if (... != ...) does not work properly with strings
| From: | ruslan2000 at mail dot com | Date: | Sun, 08 Apr 2001 18:58:54 +0000 |
| Subject: | PHP 4.0 Bug #10234: if (... != ...) does not work properly with strings | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-51150@lists.php.net to get a copy of this message | ||
From: ruslan2000@mail.com
Operating system: Win2000 Prof
PHP version: 4.0.4pl1
PHP Bug Type: Unknown/Other Function
Bug description: if (... != ...) does not work properly with strings
<?php
/*
I want to compare two strings and if they are equal show a message on the screen.
But I discovered that it's imposible, because PHP think that they are equal anyway :(((
Example of script
*/
//EX 1. something wrong
$qqq = "00041001001001001001001001001001001002000";
$xxx = "00041001001001001000000000000000000000000";
# with != just the same effect as <>
if ($qqq <> $xxx)
echo "<hr>$qqq<br> <b>!=</b> <br>$xxx<hr>"; //it
should be on the screen, but ...
else
echo "<hr>$qqq<br> <b>=</b> <br>$xxx <hr>";
//it's appear every time on the screen :(((
if ($qqq != $xxx)
echo "<hr>$qqq<br> <b>!=</b> <br>$xxx";
else
echo "<hr>$qqq<br> <b>=</b> <br>$xxx <hr>";
//(strval($qqq) != strval($xxx)) does not work too
if (strval($qqq) != strval($xxx))
echo "<hr>$qqq<br> <b>!=</b> <br>$xxx<hr>";
else
echo "<hr>$qqq<br> <b>=</b> <br>$xxx <hr>";
//EX 2 - all OK
$qqq = "00041001000000000000000000000000000000000";
$xxx = "00041001001001001001001001001001001002000";
# with != just the same effect as <>
if ($qqq <> $xxx)
echo "$qqq<br> <b>!=</b> <br>$xxx";
else
echo "$qqq<br> <b>=</b> <br>$xxx <hr>";
if ($qqq != $xxx)
echo "$qqq<br> <b>!=</b> <br>$xxx";
else
echo "$qqq<br> <b>=</b> <br>$xxx <hr>";
?>
--
Edit Bug report at: http://bugs.php.net/?id=10234&edit=1