browser detection cakephp
-
06-05-2021 - |
Question
How do you detect IE, firefox, chrome in cakephp? thanks
Pas de solution correcte
Autres conseils
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
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.....);
}
<?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
?>
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!