Cloaking

When creating a plain HTML site, you confront two paths: create a site that works great in only one browser, or create a mediocre site that works in all browsers. PHP allows you to create a site that works great in any browser. The HTTP_USER_AGENT variable contains the string most browsers send to the Web server to identify themselves. This variable may be used to choose between versions of content. This cloaks the inner workings of the site from the browser. A seamless experience is provided to visitors, despite differences in browser capabilities.

Chapter 16, "Parsing and String Evaluation," contains an example of using regular expressions to parse HTTP_USER_AGENT into understandable elements. In most cases browser name and version ...

Get Core PHP Programming: Using PHP to Build Dynamic Web Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.