From the manuals I am running a simple code to fetch browser info using get_browser()
method.
Code in the manuals -
Code I am running(almost same/i tried by removing echo "<pre>";
but no effect) -
<?php
echo $_SERVER['HTTP_USER_AGENT'] . "\n\n";
$browser = get_browser(null, true);
echo "<pre>";
print_r($browser);
?>
This is the error/illegal characters
I am getting at browser_name_regex
-
I also tried this UTF 8 encoding for characters, but problem still persist.
<!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=utf-8" />
<title>Test browser</title>
</head>
<body>
<?php
echo $_SERVER['HTTP_USER_AGENT'] . "\n\n";
$browser = get_browser(null, true);
echo "<pre>";
print_r($browser);
?>
</body>
</html>
Let me know what I am doing wrong and where to look for the solution?
One thing more to ask, in the same doc -
Attempts to determine the capabilities of the user's browser, by looking up the browser's information in the browscap.ini file.
Where do I find this browscap.ini
in my system I am using Windows 7
...although I am not very sure if it is related with this problem or not.
The same question has been asked at PHP - get_browser() results
Based on the information there and the information found at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=612364 which explains the bug more throughly, i've created some lines of code which solves the problem.
I've posted my answer both here and there.
Code:
As you told that you found browscap.in file in your given path then specify that absolute path
C:\xampp\php\extras\browscap.ini
in your php.ini file likeI have in my local setup (php.ini), actually I have generated browscap file from other function and then pasted it in file and then found correct output.
you can specify your absolute path like
and code to check