Browser detection using PHP

Today I will explain how to check what browser visitors are using with the help of user agent strings our default browser sends as a part of the HTTP request. The variable we can use to check browser is

$_server[‘http_user_agent’]

$_SERVER is a reserved super global PHP variable that contains all the web server informations.

Lets see the example and its output result.

<?php

echo $_SERVER[‘HTTP_USER_AGENT’];

?>


———————
Output

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

Leave a Reply

Your email address will not be published. Required fields are marked *