21 Mar
In php there are lot of inbuilt function you can use one of them to check browser. HTTP_USER_AGENT gives a value of all browser info. You can use it with php preg_match function. This example for only beginners to understand basic php functionality. Below is the running example to check browser type.
<?php $browser = getenv("HTTP_USER_AGENT"); //echo $browser."<br />"; if (preg_match("/Opera/i", "$browser")) { echo "You are using Opera. <br />"; } else if (preg_match("/MSIE/i","$browser")) { echo "You are using Microsoft Internet Explorer. <br />"; } else if (preg_match("/Firebird/i","$browser")) { echo "You are using Mozilla FireBird. <br />"; } else if (preg_match("/Netscape/i","$browser")) { echo "You are using Netscape. <br />"; } else if (preg_match("/Chrome/i","$browser")) { echo "You are using Chrome."; } else if (preg_match("/Mozilla/i","$browser")) { echo "You are using Mozilla."; } ?>
$browser variable gives you all possible values and you can use it smartly. It’s very basic more you can do with php inbuilt functions.
I am a software engineer who specializes in Internet applications. I have worked with a wide variety of technologies and programming languages to open source LAMP environments. I have more than 6 years of object-oriented programming experience and am highly proficient in ActionScript, PHP, MYSQL, JavaScript, Jquery and a multitude of other technologies used in modern web applications.
Follow me
Latest posts by Rajeev Achra (see all)
- Jquery webcam plugin - June 19, 2016
- How To Add and Delete Users on a CentOSServer - June 5, 2016
- How To Set Up vsftpd on CentOS 6 - June 5, 2016