jQuery 1.x and 2.x detecting browser with PHP
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
-
- <?php
-
- // JQuery 1.x and 2.x URLs
- $jQuery1 = 'jquery-1.11.2.min.js';
- $jQuery2 = 'jquery-2.1.1.min.js';
-
- // Default
- $jQuery = $jQuery2;
-
- // User Agent
- $arr = explode(' ',mb_strtolower(str_replace(array('.','/'),' ',$_SERVER['HTTP_USER_AGENT']), 'UTF-8'));
-
- for($i=0; $i < count($arr); $i++){
- if($arr[$i] == "msie"){ // Internet Explorer ?
- if($arr[$i+1] <= 8){ // <= 8 version ?
- $jQuery = $jQuery1; // Jquery 1.x
- }
- }
- }
-
- // Print
- echo '<script src="'.$jQuery.'"><script>';
- ?>
-
-
- </head>
-
- <body>
- </body>
- </html>