note 106162 added to tutorial.useful
| From: | qiang1012 at gmail dot com | Date: | Sat, 15 Oct 2011 02:47:37 +0000 |
| Subject: | note 106162 added to tutorial.useful | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183896@lists.php.net to get a copy of this message | ||
<?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)
----
Server IP: 69.147.83.197
Probable Submitter: 122.235.249.243
----
Manual Page -- http://www.php.net/manual/en/tutorial.useful.php
Edit -- https://master.php.net/note/edit/106162
Del: integrated -- https://master.php.net/note/delete/106162/integrated
Del: useless -- https://master.php.net/note/delete/106162/useless
Del: bad code -- https://master.php.net/note/delete/106162/bad+code
Del: spam -- https://master.php.net/note/delete/106162/spam
Del: non-english -- https://master.php.net/note/delete/106162/non-english
Del: in docs -- https://master.php.net/note/delete/106162/in+docs
Del: other reasons-- https://master.php.net/note/delete/106162
Reject -- https://master.php.net/note/reject/106162
Search -- https://master.php.net/manage/user-notes.php