Page 1 of 1
Exclamation Point meaning
Posted: Tue Aug 12, 2008 12:53 pm
by Stela
Hello,
I know what this code is doing, but I cant understand the exclamation point.
<?php
$name1 = "John";
$name2 = "john";
$result = strcasecmp($name1, $name2);
if(!$result)
{
echo "They match!";
}
?>
Is it a special character?
Is it the same as "!=" ?
Thank you!
Re: Exclamation Point meaning
Posted: Tue Aug 12, 2008 1:06 pm
by EducatedFool
int strcasecmp ( string $str1 , string $str2 )
Returns < 0 if str1 is less than str2 ; > 0 if str1 is greater than str2 , and 0 if they are equal.
in your case $result is 0 'cause they are equal.
!var means 'not'. So if $results != true or != 0.
true = 1
false = 0
I hope you understand what I'm saying.
Re: Exclamation Point meaning
Posted: Tue Aug 12, 2008 6:24 pm
by califdon
Stela wrote:Is it a special character?
Is it the same as "!=" ?
Yes. It reverses the meaning of whatever follows. That's not quite the same as != , which is a comparison operator.
Re: Exclamation Point meaning
Posted: Tue Aug 12, 2008 8:41 pm
by Stela
Now I get it
Just one more small question,
Does " ! " have a "group" name, like Wildcards, Comparison Operator?
I just wanna know if there are others like " ! " and were do I find them in the Manual.
Re: Exclamation Point meaning
Posted: Tue Aug 12, 2008 9:16 pm
by califdon
I suppose it would be called a negation operator.
Here's the official skinny:
http://us.php.net/manual/en/language.operators.php
Re: Exclamation Point meaning
Posted: Tue Aug 12, 2008 9:27 pm
by Stela