How to check whether the browser is IE8 or less using php?
Asked
Active
Viewed 5,748 times
4
-
I tried $_SERVER['HTTP_USER_AGENT'] and it was giving me "mozilla" when i chekc it on IE. Thats the reason I posted this question. Sorry, forgot to mention it . – user1074803 Jul 18 '12 at 04:19
-
I up voted this question because it is exactly what I need too. What have I tried? Well of course the first thing I tried was stackoverflow :). The answers so far do not address the question. How to detect, in PHP, if the browers is IE8 or less. I need this in Php so that I can adjust a Drupal theme to not generate some content on the most painful browser in history. Further search and found this question in SO http://stackoverflow.com/questions/671890/can-i-detect-ie6-with-php that also refers to http://www.useragentstring.com/pages/Internet%20Explorer/ – Bryan Nov 07 '12 at 19:31
-
See SO answer http://stackoverflow.com/questions/671890/can-i-detect-ie6-with-php – Bryan Nov 07 '12 at 20:03
4 Answers
4
EDIT
<?php
//echo $_SERVER['HTTP_USER_AGENT'] . "\n\n";
$browser = get_browser(null, true);
echo "<pre>";
print_r($browser['version']);
?>

swapnesh
- 26,318
- 22
- 94
- 126
-5
$(document).ready(function(){
var bro=$.browser;
var binfo="";
if(bro.msie) {binfo="Microsoft Internet Explorer "+bro.version;}
if(bro.mozilla) {binfo="Mozilla Firefox "+bro.version;}
if(bro.safari) {binfo="Apple Safari "+bro.version;}
if(bro.opera) {binfo="Opera "+bro.version;}
alert(binfo);
$("#browser").html(binfo);
})

Mushahid Hussain
- 4,052
- 11
- 43
- 62

Cohlint
- 6
- 1
-
7
-
Not only does this not include any php, but it also requires jquery. This is a good answer, but not for this question. – Ian Feb 03 '15 at 15:55