can someone explain this one to me? a link to something in the php manual even?? i can't find anything:
if ($_SERVER['SERVER_PORT'] <> 443) {
doSomething();
}
can someone explain this one to me? a link to something in the php manual even?? i can't find anything:
if ($_SERVER['SERVER_PORT'] <> 443) {
doSomething();
}
It's another way of saying "not equal to" (the !=
operator). I think of it as the "less than or greater than" operator which really just means "not equal to".
$_SERVER['SERVER_PORT']
gets the port used by the web server to serve HTTP requests. $_SERVER['SERVER_PORT'] <> 443
checks if the port is not equal to 443 (the default HTTPS port) and if not, invokes doSomething()
good show! thanks to all that answered. :) loving stack overflow. :P
Note that <>
behaves as !=
even where <
and >
are not obvious comparison operators (eg $str1 <> $str2
).
Although PHP is mostly based on C-style syntax, this is one of the weird things that comes from the BASIC-style syntax world.
Needless to say, I'd just use != and be consistent with it, as <> is really never used.