I’ve got a page. But I found out that my position: relative; modification for Chrome doesn’t look to nice on Firefox, and on IE it looks, the most ugly page ever. I got a thought of creating special stylesheet for each browser (it’s easier than it seem). But the problem is, that I am busy to find working PHP script so far.
The clue is
<?php
if ($browser == "ie"){
echo "Page for IE";
}
elseif ($browser == "chrome"){
echo "Page for Chrome";
}
elseif ($browser == "firefox"){
echo "Page for Firefox";
}
elseif ($browser == "safari"){
echo "Page for Safari";
}
elseif ($browser == "opera"){
echo "Page for Opera";
}
else {
echo "Oops, our page does not support your browser. Please install one of supported";
}?>
The problem is, how I can come on $browser? I found this code tried so far.
echo $_SERVER[‘HTTP_USER_AGENT’];
But in result I get every known browser as output (at least in Chrome).
Could please anyone help me? I cannot use JS or jQuery at all.
You should use the browsecap.ini and the get_browser function. That will give you what you are looking for.
http://php.net/manual/en/function.get-browser.php