How do you detect IE, firefox, chrome in cakephp? thanks
- 
                    1This is effectively a duplicate of http://stackoverflow.com/q/5302302/327074. Since there's no specific 'cake' way of doing this – icc97 Nov 15 '13 at 10:02
 
4 Answers
Hello this is my solution to detect navigator
You can put this code in your routes.php
  if(!strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 8' ) !== TRUE) { 
router::connect(etc.....);
 }
- 11
 - 1
 
<?php
 $userAgent = $_SERVER["HTTP_USER_AGENT"];
 $msie = strpos($userAgent, 'MSIE') ? true : false; // Internet Explorer
 $firefox = strpos($userAgent, 'Firefox') ? true : false; // Firefox
 $safari = strpos($userAgent, 'Safari') ? true : false; // Webkit powered browser
 $chrome = strpos($userAgent, 'Chrome') ? true : false; // Webkit powered browser
?>
- 289
 - 3
 - 12
 
I'm not sure about cake php but http://php.net/manual/en/function.get-browser.php gives some good info and is a built in php function.
edit: spelling
- 1,889
 - 1
 - 20
 - 40
 
It depends on what you would like to do.
If it is related to CSS, I would use conditional css files Conditional CSS
If it is related to pure php, the get browser function will do ok. Here is a script that I found on google that uses it. You could probably use this in your application. Browser Class
If you can wait until the page is loaded, use Javascript. I know Mootools has its own Browser class and I would guess that jQuery does to. Here is the Mootools documentation. Mootools Browser Class
This would be my recommended solution.
Have a great day!
- 3,193
 - 1
 - 23
 - 36
 
- 
                    1This is mega old, but for people who do not know, conditional comments are no longer supported as of IE10 – MrSynAckSter Nov 19 '13 at 15:05
 - 
                    
 -