Detect Browser using PHP - Web Development and Web Design Codes

Latest

Tuesday, February 20, 2018

Detect Browser using PHP

Detect Browser using PHP

Detect Browser using PHP
Detect Browser using PHP
Hi Friends today we will learn how to detect web browser in php..
just use the below php script to detect user browser in php.
php examples: detect browser.. 1. index.php
<?php

function get_browser_name($user_agent)
{
    if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';
    elseif (strpos($user_agent, 'Edge')) return 'You are Using <b>Microsoft Edge</b>';
    elseif (strpos($user_agent, 'Chrome')) return 'You are using <b>Google Chrome</b> Web Browser';
    elseif (strpos($user_agent, 'Safari')) return 'You are using <b>Apple Safari</b>';
    elseif (strpos($user_agent, 'Firefox')) return 'You are using <b>Mozilla Firefox</b> Web Browser';
    elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'You are Using <b>Internet Explorer</b>';
    
    return 'Other';
}

// Usage:

echo '<font style=color:green size=4>'.get_browser_name($_SERVER['HTTP_USER_AGENT']).'</font>';

?>

That's it Friends how to detect browser in php..keep visiting for more codes and examples..thank you..

No comments:

Post a Comment

Thank You for Your Comment

Note: Only a member of this blog may post a comment.