Webmaster Hack – How to Detect Palm Pre!

by on Friday, March 5th, 2010

For webmasters and web designers who are tailoring their website to Palm Pres and other smartphones, here’s some free PHP code that will detect Palm Pre and other smartphones from my DIY tech blogwe:

<?php
$iphone = strpos($_SERVER['HTTP_USER_AGENT'],”iPhone”);
$android = strpos($_SERVER['HTTP_USER_AGENT'],”Android”);
$palmpre = strpos($_SERVER['HTTP_USER_AGENT'],”webOS”);
$ipod = strpos($_SERVER['HTTP_USER_AGENT'],”iPod”);
if(!$iphone && !$android && !$palmpre && !$ipod) {
?>
Your code goes here that you want only executed when it’s not a smartphone.

<?php } ?>

This could be great if you want to load a different version of your website or even just to test your website on the Palm Pre.  That way, your regular readers from desktop computers and laptops won’t get affected while you test your version of website for the Palm Pre.

Free Nexus One phones



Enter your zip code here and find out if you can qualify for 2 free Nexus One phones.

Rate

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Categories: Palm Pre Hacks.

Related News and Resources



3 Responses to “Webmaster Hack – How to Detect Palm Pre!”

  1. Elisabeth Deaner Says:

    Evaluate & Preserve your iPad for Free of cost! -> http://bit.ly/cFBuis

  2. Piseth Says:

    Thanks for sharing the code

  3. keith Says:

    This didn’t work until I changed the double quotes to single quotes. Then it worked like a charm.

Leave a Reply

Featured Sites from Our Network