Identify The Browser [Client side script(java script) and Server side script(PHP)]

PHP Script for get browser

<?php
function getBrowser()
    {
        $u_agent = $_SERVER['HTTP_USER_AGENT'];
        $ub = '';
        if(preg_match('/MSIE/i',$u_agent))
        {
            $ub = "Internet Explorer";
        }
        elseif(preg_match('/Firefox/i',$u_agent))
        {
            $ub = "Mozilla Firefox";
        }
        elseif(preg_match('/Safari/i',$u_agent))
        {
            $ub = "Apple Safari";
        }
        elseif(preg_match('/Chrome/i',$u_agent))
        {
            $ub = "Google Chrome";
        }
        elseif(preg_match('/Flock/i',$u_agent))
         {
            $ub = "Flock";
        }
        elseif(preg_match('/Opera/i',$u_agent))
        {
            $ub = "Opera";
        }
        elseif(preg_match('/Netscape/i',$u_agent))
        {
            $ub = "Netscape";
        }
        return $ub;
    }

?>
<?php $browername= getbrowser();
if($browername == "Mozilla Firefox"){
$logoname="logo_mz.png";
}else{
$logoname="vote_new1.png";
}

Java Script for get browser

<script type="text/javascript">
if (navigator.userAgent.indexOf("Firefox")!=-1)
{
document.write("You are in Mozilla browser")
}
else{
document.write("You are not in Mozilla")
}
</script>
Advertisements
Posted in ALL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s