strcasecmp()
| From: | Anthony Ritter | Date: | Sun, 29 Aug 2004 14:48:03 +0000 |
| Subject: | strcasecmp() | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-195077@lists.php.net to get a copy of this message | ||
<?
$first_name = "Hello";
$second_name = "Hello";
if(strcasecmp($first_name,$second_name)) {
echo "words are equal";
}
else
{
echo "words are not equal.";
}
?>
..............
In strcasecmp() - this comparison will return 0 - interpreted by PHP as
FALSE - eventhough words are _equal_ so what will execute is "words are not
equal".
whereas if the negation symbol of ! is inserted as in:
.......
<?
$first_name = "Hello";
$second_name = "Hello";
if(!strcasecmp($first_name,$second_name)) {
echo "words are equal";
}
else
{
echo "words are not equal.";
}
?>
...........
to read if the comparsion which is returned is not _FALSE_ excecute:
"words are equal."
.............
Am I on the right track with this logic?
Thank you.
TR