mattal999 Posted September 12, 2008 Share Posted September 12, 2008 Hi, I have this: <?php $browser=strtolower($_SERVER['HTTP_USER_AGENT']); if(strpos($browser, 'msie')) { ?> <link rel="stylesheet" type="text/css" href="css/style.css" /> <?php } else if(strpos($browser, 'chrome')) { ?> <link rel="stylesheet" type="text/css" href="css/stylechrome.css" /> <?php } else if(strpos($browser, 'firefox')) { ?> <link rel="stylesheet" type="text/css" href="css/styleff.css" /> <?php } else if(strpos($browser, 'opera')) { ?> <link rel="stylesheet" type="text/css" href="css/styleopera.css" /> <?php } else { ?> <link rel="stylesheet" type="text/css" href="css/styleff.css" /> <?php } ?> And i have checked Opera's output of $browser, which is: opera/9.51 (windows nt 5.1; u; en) However, it doesn't detect the word opera in that phrase!!! Help! Link to comment https://forums.phpfreaks.com/topic/123970-solved-php-browser-check/ Share on other sites More sharing options...
mattal999 Posted September 12, 2008 Author Share Posted September 12, 2008 Bump Link to comment https://forums.phpfreaks.com/topic/123970-solved-php-browser-check/#findComment-640040 Share on other sites More sharing options...
The Little Guy Posted September 12, 2008 Share Posted September 12, 2008 is it case sensitive? Link to comment https://forums.phpfreaks.com/topic/123970-solved-php-browser-check/#findComment-640042 Share on other sites More sharing options...
DarkWater Posted September 12, 2008 Share Posted September 12, 2008 Try stripos(). Link to comment https://forums.phpfreaks.com/topic/123970-solved-php-browser-check/#findComment-640047 Share on other sites More sharing options...
mattal999 Posted September 12, 2008 Author Share Posted September 12, 2008 1: I used strtolower -.- 2: I don't have stripos... Any other ideas? Link to comment https://forums.phpfreaks.com/topic/123970-solved-php-browser-check/#findComment-640055 Share on other sites More sharing options...
DarkWater Posted September 12, 2008 Share Posted September 12, 2008 1: I used strtolower -.- 2: I don't have stripos... Any other ideas? You're using PHP4...? Why? Link to comment https://forums.phpfreaks.com/topic/123970-solved-php-browser-check/#findComment-640058 Share on other sites More sharing options...
hamza Posted September 12, 2008 Share Posted September 12, 2008 yeah it is working fine with the browser's there must be a little problem i dont have opera so its quite difficult to try thsi problem but change anyother php funtion other then this strpos because function in php are not 100% successfully running every time there are many problems in fucntion some time it works sometimes not,. so i suggest you to change or use any other one thanks and regards Link to comment https://forums.phpfreaks.com/topic/123970-solved-php-browser-check/#findComment-640194 Share on other sites More sharing options...
DarkWater Posted September 13, 2008 Share Posted September 13, 2008 yeah it is working fine with the browser's there must be a little problem i dont have opera so its quite difficult to try thsi problem but change anyother php funtion other then this strpos because function in php are not 100% successfully running every time there are many problems in fucntion some time it works sometimes not,. so i suggest you to change or use any other one thanks and regards ...What? Also, your problem is that you're not using strpos() correctly. strpos() returns the position of the found string, correct? If it finds the string at position 0 in your big string, it returns 0. If used as you have it set up, this evaluates to FALSE and then doesn't activate the if. You need to do: if (strpos($browser, 'opera') !== false) { } That should be done for ALL of them, and any other time you use strpos, btw. Link to comment https://forums.phpfreaks.com/topic/123970-solved-php-browser-check/#findComment-640217 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.