PHP

How to get Browser Information In PHP

A Browser is application software used to open web pages from servers or over the internet. A browser is application software which displays content from the World Wide Web, which includes images, video etc. Today there are many browsers available in the market.
Some browsers are as follows:

  • Intenet Explorer
  • Firebox
  • Google Chrome
  • Safari etc…

To Find Browser Name in PHP
If you want to know a browser name through PHP then you can do that. For this purpose you will use the following code.

<html>
<body>
<h4>Browser Information</h4>
<?php
$browser="";
if(strrpos(strtolower($_SERVER["HTTP_USER_AGENT"]),strtolower("MSIE")))
{
$browser="Internet Explorer";
}
else if(strrpos(strtolower($_SERVER["HTTP_USER_AGENT"]),strtolower("Presto")))
{
$browser="Opera";
}
else if(strrpos(strtolower($_SERVER["HTTP_USER_AGENT"]),strtolower("CHROME")))
{
$browser="Google Chrome";
}
else if(strrpos(strtolower($_SERVER["HTTP_USER_AGENT"]),strtolower("SAFARI")))
{
$browser="Safari";
}
else if(strrpos(strtolower($_SERVER["HTTP_USER_AGENT"]),strtolower("FIREFOX")))
{
$browser="FIREFOX";
}
else
{
$browser="OTHER";
}
echo "Your Browser is :" .$browser;
?>
</body>
</html>

Recommended Tutorials for you


Related posts

How to convert number to String in PHP

Anuj Kumar

Captcha Image Verification

Anuj Kumar

PHP Constants

Anuj Kumar

PHP – PECL

Anuj Kumar

How to prevent Cross-Site Request Forgery (CSRF) in PHP

Anuj Kumar

Password Hashing in PHP

Anuj Kumar

How to insert data into MySql using PHP

Anuj Kumar

PHP – Variables

Anuj Kumar

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.