Click here to Skip to main content
13,288,104 members (53,490 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 3 Jul 2011

PHP browser detector

, 3 Jul 2011
Rate this:
Please Sign up or sign in to vote.
Code to detect browser name in PHP.

The following code provides a simple PHP browser detection method which only echos the name of the browser used by the user.

else if(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]),strtolower("Presto"))){$browser="opera";}
else if(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]),strtolower("CHROME"))){$browser="chrome";}
else if(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]),strtolower("SAFARI"))){$browser="safari";}
else if(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]),strtolower("FIREFOX"))){$browser="firefox";}
else {$browser="other";}
echo $browser;

Note: I have posted this tip in order to help beginners like myself as I have faced this same problem. Please feel free to correct me if I am wrong.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Bahrain Bahrain
This member doesn't quite have enough reputation to be able to display their biography and homepage.

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171207.1 | Last Updated 3 Jul 2011
Article Copyright 2011 by vergil135
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid