Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Wednesday, 20 April 2016

Browser Detection in PHP

Browser Detection in PHP

  1. <?php
  2. $ie = strpos($_SERVER["HTTP_USER_AGENT"], 'IE') ? true : false;
  3. $M_firefox = strpos($_SERVER["HTTP_USER_AGENT"], 'Firefox') ? true : false;
  4. $safari = strpos($_SERVER["HTTP_USER_AGENT"], 'Safari') ? true : false;
  5. $G_chrome = strpos($_SERVER["HTTP_USER_AGENT"], 'Chrome') ? true : false;
  6. ?>
//// Apply condtion for further Uses..../////
  1. <?php
  2. //Firefox
  3. if ($M_firefox) {
  4. echo 'you are using Firefox!';
  5. echo '<br />';
  6. }
  7. // Both(Safari or Chrome) use the same engine - webkit
  8. if ($safari || $G_chrome) {
  9. echo 'your browser is a webkit powered browser(Chrome Or Safari)';
  10. echo '<br />';
  11. }
  12. // IE
  13. if ($ie) {
  14. echo '<br>your browser is Internet Explorer<br>';
  15. echo '<br />';
  16. }
  17. // Not IE and for all other browsers
  18. if (!$ie) {
  19. echo '<br>your browser is not Internet Explorer<br>';
  20. echo '<br />';
  21. }
  22. ?>
If you like it , then don't forgot to share it!

No comments:

Post a Comment