News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Sameer Borate's Blog:
Detecting user agents in PHP
October 07, 2009 @ 08:21:22

In a new post to his blog today Sameer looks at a trick or two about detecting the type of browser/client a visitor is using to view your website - one method with the superglobal and another with a helpful PEAR package.

Every time you use your browser to access a website a User-Agent header is sent to the respective server. Detecting user agents on the server can be useful for many reasons: browser quirks, personalize content, preventing illegal access.

He talks about the get_browser function that's included in PHP but that requires a browscap.ini file to work. His other option is the Net_UserAgent_Detect PEAR package. It grabs the user agent and breaks it up into the browser type, operating system information and any Javascript-related headers that come along with it. There's also useful tests like "isIE()" and "isNetscape()" built into the package.

0 comments voice your opinion now!
detecting user agent pear


blog comments powered by Disqus

Similar Posts

Community News: Latest PEAR Releases for 11.13.2006

Development Seed Blog: Simple Sign-On with OpenID

Chuck Burgess' Blog: Configuring Builds for PEAR Packages in phpUnderControl

Lorenzo Alberton's Blog: PEAR::Pager - Navigation with Pager and AJAX (or simple Javascript)

Joshua Eichorn's Blog: Slides from azPHP presentation of PEAR: An Introduction


Community Events





Don't see your event here?
Let us know!


opinion framework library laravel version series update community language security application symfony introduction tool voicesoftheelephpant package interview release composer podcast

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework