Hello Reader! If you are developing the website which depends on user's web browser then you must first find out the web browser that is opened. By using PHP you can get easily this info using the library code below:-
<?php
function detect_web_browser()
{
$u_agent = $_SERVER['HTTP_USER_AGENT'];
$ub = '';
if(preg_match('/MSIE/i',$u_agent))
{
$ub = "ie";
}
elseif(preg_match('/Firefox/i',$u_agent))
{
$ub = "firefox";
}
elseif(preg_match('/Safari/i',$u_agent))
{
$ub = "safari";
}
elseif(preg_match('/Chrome/i',$u_agent))
{
$ub = "chrome";
}
elseif(preg_match('/Flock/i',$u_agent))
{
$ub = "flock";
}
elseif(preg_match('/Opera/i',$u_agent))
{
$ub = "opera";
}
return $ub;
}
?>
Output:-
$user_browser = detect_web_browser();
if($user_browser == "Firefox"){
//Now code for firefox
}
0 Comment(s)