Jump to content

Identifying Browser


jim.davidson

Recommended Posts

All you need to read the browser is the User Agent. PHP includes a method for Apache servers using the global $_SERVER.

 

<?php
$userAgent = $_SERVER["HTTP_USER_AGENT"];
//Parse out the browser from here
?>

 

Edit:

I didn't realize this but PHP also offers a function called get_broswer();  But it will only work with certain PHP configurations.

 

<?php
$browser = get_browser(null, true);
print_r($browser);
?>

Link to comment
https://forums.phpfreaks.com/topic/72315-identifying-browser/#findComment-364631
Share on other sites

I'm confused..I just tested that and it says I'm running Mozilla but I'm testing in IE

 

Here's the code  and the result

 

<?php


$userAgent = $_SERVER["HTTP_USER_AGENT"];
echo $userAgent;

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>

 

 

 

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727)

Link to comment
https://forums.phpfreaks.com/topic/72315-identifying-browser/#findComment-364644
Share on other sites

Im running Safari got

 

Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/522.11.1 (KHTML, like Gecko) Version/3.0.3 Safari/522.12.1

 

But the code is gathering accurate data. It reads that Im using webkit and everything. But it does mention Mozilla.

 

Here's yours

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727)

 

Yours Says that your using Internet Explorer 6 (upgrade to firefox!! lol) and your on Windows XP. So I'd imagine I just described your machine.

 

Hopefully someone with better Knowledge can explain why there's Mozilla in the front of the User Agent.

Link to comment
https://forums.phpfreaks.com/topic/72315-identifying-browser/#findComment-364651
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.