ID: 10234
Updated by: cnewbill
Reported By: [EMAIL PROTECTED]
Old-Status: Open
Status: Bogus
Bug Type: Unknown/Other Function
Assigned To: 
Comments:

For string comparison use !== for NOT and === for EQUALS.

-Chris

Previous Comments:
---------------------------------------------------------------------------

[2001-04-08 14:58:54] [EMAIL PROTECTED]
<?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>";

?>

---------------------------------------------------------------------------



ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=10234&edit=2


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to