note 100831 deleted from function.get-browser by danbrown

From: Date: Wed, 10 Nov 2010 13:49:03 +0000
Subject: note 100831 deleted from function.get-browser by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-173902@lists.php.net to get a copy of this message
Note Submitter: arnel_milan at hotmail dot com ---- For all shared hosting users: 1. Using htaccess to trigger the browscap will not work. This is one of the limitation of htaccess for setting a customized php variables. 2. One of the best solution is the "PHPBROWSCAP" class which can be downloaded here https://github.com/garetjax/phpbrowscap 3. It maybe tricky but the code will simply work by using the http://code.google.com/p/phpbrowscap/wiki/QuickStart 4. The key to make that class work is to create a "cache" folder and make it writable. Below are the codes : /** * @author ARNEL MILAN * @copyright 2010 */ $agent = $_SERVER['HTTP_USER_AGENT']; require ("lib/browscap.php"); // Creates a new Browscap object (loads or creates the cache) $bc = new Browscap('cache'); // Create this folder // Gets information about the current browser's user agent $current_browser = $bc->getBrowser($agent); // Output the result echo '<pre>'; // some formatting issues ;) print_r($current_browser); echo '</pre>'; Hope this help!

« previous php.notes (#173902) next »