note 106798 added to tutorial.useful
| From: | JayWalker at osu1 dot php dot net | Date: | Wed, 07 Dec 2011 06:09:44 +0000 |
| Subject: | note 106798 added to tutorial.useful | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-184967@lists.php.net to get a copy of this message | ||
Suggesting a better way to detect the Firefox browser:
I see that, at least for a recent download of the Firefox browser,
the PHP command:
<?php
echo $_SERVER['HTTP_USER_AGENT'];
?>
returns:
Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20100101 Firefox/8.0
...
So, note the term 'Firefox' in the returned string,
and therefore you can search for the substring 'Firefox'.
Therefore the PHP code:
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== FALSE)
{
echo 'I see you are using Mozilla Firefox browser.<br />';
}
?>
works just fine.
----
Server IP: 69.147.83.197
Probable Submitter: 75.69.184.188
----
Manual Page -- http://www.php.net/manual/en/tutorial.useful.php
Edit -- https://master.php.net/note/edit/106798
Del: integrated -- https://master.php.net/note/delete/106798/integrated
Del: useless -- https://master.php.net/note/delete/106798/useless
Del: bad code -- https://master.php.net/note/delete/106798/bad+code
Del: spam -- https://master.php.net/note/delete/106798/spam
Del: non-english -- https://master.php.net/note/delete/106798/non-english
Del: in docs -- https://master.php.net/note/delete/106798/in+docs
Del: other reasons-- https://master.php.net/note/delete/106798
Reject -- https://master.php.net/note/reject/106798
Search -- https://master.php.net/manage/user-notes.php