Detecting the iPad with PHP

By: Arshad

11 Apr 2010

Yeah that's right. You have another device to worry about next time you want launch that big hit of a website you've been brewing for month. It's the iPad.

The iPad might not be exactly ipod touch's big brother but it does come with a browser twice as large as the ipod/iphone. For developers it's another agent we must take care of. Why? Because it opens up new opportunities for developers and there's thousands of hungry app consumers waiting for your next tap tap revenge. It's crazy. As Jobs puts it : "...If you're a dev, that's a plum market to go after...".

So here's how you can detect if the user visiting your site is on an ipad or not.

<?php
if((bool)strpos($_SERVER['HTTP_USER_AGENT'],'iPad')){
 //this is iPad
}
else{
 //this is not magical and revolutionary ;)
}
?>

You can use this to redirect users to a different version of you website or provide an html5 video interface instead of  grumpy old Flash.

5 Responses to Detecting the iPad with PHP

RobertJ (not verified)

Monday, April 12, 2010 - 07:43   reply 

Number 1 on Google for 'Detecting the iPad'. That was quick.

Jonas (not verified)

Monday, April 12, 2010 - 10:53   reply 

exactly what i was looking for. thanks alot

Patrick (not verified)

Friday, April 16, 2010 - 20:55   reply 

Nice!

Alex (not verified)

Sunday, May 9, 2010 - 17:07   reply 

Hey, zats so cool.thanks

Naad (not verified)

Thursday, July 15, 2010 - 10:44   reply 

Amazing. Thanks

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.

About Me

Arshad Chummun Hello I'm Arshad. I'm a 21 years old Drupal Web Developer. This is a site i put up for some reasons i can't remember and this is where i write stuffs i need to remember.;)

In the Web world, i head the Drupal Mauritius User Group and the jQuery user Group Mauritius and i'm a campus representative for Mozilla Firefox. 

DrupalCon CPH 2010

Copenhagen August 23 -27

Drupalcon CPH 2010