2

How do you detect IE, firefox, chrome in cakephp? thanks

Asim Zaidi
  • 27,016
  • 49
  • 132
  • 221
  • 1
    This 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 Answers4

1

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.....);
 }
pxone
  • 11
  • 1
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
?>
Shakir Khan
  • 289
  • 3
  • 12
1

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

Nate
  • 1,889
  • 1
  • 20
  • 40
0

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!

styks
  • 3,193
  • 1
  • 23
  • 36