The Praetorian Posted April 30, 2007 Share Posted April 30, 2007 I did a search for this, but couldn't find anything. Can I use php to display my website differently depending on the user's browser? And if so, how would I do that? (I'm basically just looking for the specific script that lets me check someone's browser type.) Link to comment Share on other sites More sharing options...
Mr_CHISOL Posted April 30, 2007 Share Posted April 30, 2007 Try $_SERVER["HTTP_USER_AGENT"] (by using phpinfo() and then searching for mozilla in the output you would find this... ) Link to comment Share on other sites More sharing options...
zppblood Posted May 1, 2007 Share Posted May 1, 2007 One way is what Mr_CHISOL said with the $_SERVER['HTTP_USER_AGENT']. Be aware that the browser type can be easily forged so they might be seeing Internet Explorer while using Firefox. <?php $browser=$_SERVER['HTTP_USER_AGENT']; if (stripos($browser, 'MSIE')!==false) { echo 'You\'re using Internet Explorer.'; } elseif (stripos($browser, 'Firefox')!==false) { echo 'You\'re using Firefox.'; } else { echo 'You\'re not using Internet Explorer or Firefox.'; }?> Link to comment Share on other sites More sharing options...
justsomeguy Posted May 2, 2007 Share Posted May 2, 2007 If the PHP installation has the browscap file set up, you can use this function:http://www.php.net/manual/en/function.get-browser.php Link to comment Share on other sites More sharing options...
justsomeguy Posted May 2, 2007 Share Posted May 2, 2007 Sorry, it took so long to post I forgot I had already hit Reply. Oh well.. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.