Monday, January 23, 2006

PHP and the PSP?

Shazaam! Recently built Playstation Portables (PSPs) have a web
browser and wireless access built right in. But what's that got
to do with PHP? Plenty, as you'll soon see.

To take advantage of this phenomemon, you'll need web pages
optimized for the PSP's 480-pixel-wide screen. Next, you'll need
to detect when a visitor found your site with his/her PSP. That's
where the PHP bit comes in.

This code: (Replace the [ and ] with angle-brackets.)

[?php
if(eregi("PlayStation Portable", $_SERVER['HTTP_USER_AGENT']) ) {
header("Location: http://www.yoursite.com/psp/index.html");
die();
}
?]


will detect the PSP browser and redirect the visitor to a different
page that looks good on a PSP. All links on that page should go to
other pages that were also made PSP-friendly.

The code needs to be placed at the top of your normal index page
or any other page where the visitor might land on your site.

Happy Coding!