note 106162 deleted from tutorial.useful by tularis
| From: | tularis@php.net | Date: | Thu, 08 Dec 2011 14:40:19 +0000 |
| Subject: | note 106162 deleted from tutorial.useful by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-184979@lists.php.net to get a copy of this message | ||
Note Submitter: qiang1012 at gmail dot com
----
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla') != FALSE) {
echo 'You are using Mozilla Firefox.<br />';
}
?>
I ran the codes above in Firefox, the result was not what I had expected.
Finally, I figured out that:
1. strpos('Mozilla xxxx', 'Mozilla') returns 0 which equals to FALSE.
2. I typed "!==" as "!=", they have different effects.
Below is some snippets from http://www.php.net/manual/en/language.operators.comparison.php
$a != $b Not equal TRUE if $a is not equal to $b after type juggling.
$a !== $b Not identical TRUE if $a is not equal to $b, or they are not of the same type.
(introduced in PHP 4)