{"id":229,"date":"2012-06-01T08:00:48","date_gmt":"2012-06-01T08:00:48","guid":{"rendered":"http:\/\/pixert.com\/blog\/?p=229"},"modified":"2012-05-31T12:53:48","modified_gmt":"2012-05-31T12:53:48","slug":"php-conditional-statement-to-identify-ipad-or-ipod-or-iphone","status":"publish","type":"post","link":"https:\/\/pixert.com\/blog\/php-conditional-statement-to-identify-ipad-or-ipod-or-iphone\/","title":{"rendered":"PHP Conditional statements to identify iPad or iPod or iPhone"},"content":{"rendered":"<p><a href=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/05\/ipadiphoneipod.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"232\" data-permalink=\"https:\/\/pixert.com\/blog\/php-conditional-statement-to-identify-ipad-or-ipod-or-iphone\/ipadiphoneipod\/\" data-orig-file=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/05\/ipadiphoneipod.jpg?fit=649%2C540&amp;ssl=1\" data-orig-size=\"649,540\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"ipadiphoneipod\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/05\/ipadiphoneipod.jpg?fit=300%2C249&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/05\/ipadiphoneipod.jpg?fit=649%2C540&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/05\/ipadiphoneipod-300x249.jpg?resize=300%2C249\" alt=\"\" title=\"ipadiphoneipod\" width=\"300\" height=\"249\" class=\"aligncenter size-medium wp-image-232\" srcset=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/05\/ipadiphoneipod.jpg?resize=300%2C249&amp;ssl=1 300w, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/05\/ipadiphoneipod.jpg?w=649&amp;ssl=1 649w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nThis tutorial will show you how to detect iPad or iPod or iPhone using PHP<br \/>\nDevices which request content from your website (usually) pass a user agent string. This contains information such as its name, OS, browser version, and rendering engine. Apple\u2019s gadgets pass the following user agents, although you may find subtle variations in the version numbers<\/p>\n<p>iPad user agent<\/p>\n<pre class=\"brush: php; title: Code Block; notranslate\" title=\"Code Block\">\r\nMozilla\/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit\/531.21.10 (KHTML, like Gecko) Version\/4.0.4 Mobile\/7B334b Safari\/531.21.10\r\n<\/pre>\n<p>iPhone user agent<\/p>\n<pre class=\"brush: php; title: Code Block; notranslate\" title=\"Code Block\">\r\nHTTP_USER_AGENT=Mozilla\/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit\/420+ (KHTML, like Gecko) Version\/3.0 Mobile\/1C25 Safari\/419.\r\n<\/pre>\n<p>iPhone user ageny<\/p>\n<pre class=\"brush: php; title: Code Block; notranslate\" title=\"Code Block\">\r\nMozilla\/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit\/420.1 (KHTML, like Gecko) Version\/3.0 Mobile\/3A101a Safari\/419.3  \r\n<\/pre>\n<p>The following conditional statements can be used to identify iPad or iPod or iPhone<\/p>\n<pre class=\"brush: php; title: Code Block; notranslate\" title=\"Code Block\">\r\nif (preg_match(&quot;\/iP(od|hone|ad)\/i&quot;, $_SERVER&#x5B;&quot;HTTP_USER_AGENT&quot;])) { ... }\r\n<\/pre>\n<p>or<\/p>\n<pre class=\"brush: php; title: Code Block; notranslate\" title=\"Code Block\">\r\nif(strstr($_SERVER&#x5B;'HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER&#x5B;'HTTP_USER_AGENT'],'iPod') || strstr($_SERVER&#x5B;'HTTP_USER_AGENT'],'iPad')) { }\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial will show you how to detect iPad or iPod or iPhone using PHP Devices which request content from your website (usually) pass a user agent string. This contains information such as its name, OS, browser version, and rendering engine. Apple\u2019s gadgets pass the following user agents, although you may find subtle variations in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":232,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[54,25,40,5],"tags":[105,149,102,103,104,39,6],"class_list":["post-229","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-code-snippet","category-ios","category-web-apps","category-wordpress","tag-conditional","tag-ios","tag-ipad","tag-iphone","tag-ipod","tag-php","tag-wordpress-2"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/05\/ipadiphoneipod.jpg?fit=649%2C540&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1pvi1-3H","jetpack-related-posts":[{"id":227,"url":"https:\/\/pixert.com\/blog\/mp4-video-cannot-play-on-ipad-ipod-iphone-using-jw-player-shortocode\/","url_meta":{"origin":229,"position":0},"title":"MP4 video cannot play on iPad\/iPod\/iPhone using JW Player shortcode","author":"Pixel Insert \/ Pixert","date":"May 14, 2012","format":false,"excerpt":"It seems that this is a bug on JW Player for WordPress plugin We added JW Player or WordPress plugin shortcode with a mp4 video in it, the video plays on Macbooks and PCs, but it shows blank on iPad or iPod or iPhone. Although HTML5 as default mode, it\u2026","rel":"","context":"In &quot;iOS&quot;","block_context":{"text":"iOS","link":"https:\/\/pixert.com\/blog\/category\/ios\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3,"url":"https:\/\/pixert.com\/blog\/how-to-create-epub-ebooks-and-transfer-it-to-stanza\/","url_meta":{"origin":229,"position":1},"title":"How to Create ePub ebooks and transfer it to Stanza","author":"Pixel Insert \/ Pixert","date":"March 18, 2011","format":false,"excerpt":"ePub is the Open eBook standard from the International Digital Publishing Forum. Files have the extension \".epub\" Stanza is electronic book reader and book sharing software for iPhone\/iPod Touch and iPad. Here's how you can convert nearly any eBook format to ePub on Windows or Mac OS. We're using free\u2026","rel":"","context":"In &quot;Mac OS&quot;","block_context":{"text":"Mac OS","link":"https:\/\/pixert.com\/blog\/category\/mac-os\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":512,"url":"https:\/\/pixert.com\/blog\/whatsapp-on-ipad\/","url_meta":{"origin":229,"position":2},"title":"How to use WhatsApp on iPad","author":"Pixel Insert \/ Pixert","date":"May 7, 2019","format":false,"excerpt":"WhatsApp is a great tool for communication. It is available for iPhone, but not for iPad. However, we can use the desktop version, WhatsApp for Web to make it work on iPad","rel":"","context":"In &quot;Web Apps&quot;","block_context":{"text":"Web Apps","link":"https:\/\/pixert.com\/blog\/category\/web-apps\/"},"img":{"alt_text":"WhatsApp on iPad: how to show WhatsApp for Web on iPad","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2019\/05\/40975F0D-F6E9-46C6-9A11-F35197A9C7E0.jpeg?fit=916%2C1200&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2019\/05\/40975F0D-F6E9-46C6-9A11-F35197A9C7E0.jpeg?fit=916%2C1200&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2019\/05\/40975F0D-F6E9-46C6-9A11-F35197A9C7E0.jpeg?fit=916%2C1200&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2019\/05\/40975F0D-F6E9-46C6-9A11-F35197A9C7E0.jpeg?fit=916%2C1200&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":46,"url":"https:\/\/pixert.com\/blog\/change-mamp-mysql-password\/","url_meta":{"origin":229,"position":3},"title":"Change MAMP MySQL password","author":"Pixel Insert \/ Pixert","date":"March 12, 2011","format":false,"excerpt":"MAMP creates a local server environment on Mac OS X by installing Apache, PHP and MySQL right out of the box. The default username\/password for MySQL install is root\/root. That's not safe. For security purposes, in our case we want sync between our WAMP and MAMP , it's best to\u2026","rel":"","context":"In &quot;Mac OS&quot;","block_context":{"text":"Mac OS","link":"https:\/\/pixert.com\/blog\/category\/mac-os\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/mamplogo.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":538,"url":"https:\/\/pixert.com\/blog\/update-php-in-2021\/","url_meta":{"origin":229,"position":4},"title":"Update PHP in the year of 2021","author":"Pixel Insert \/ Pixert","date":"February 23, 2021","format":false,"excerpt":"I saw a notification to update PHP on the WordPress Dashboard of this blog. I saw in the server's Control Panel that PHP has been setup to version 7.3. I then saw the Requirements page on the wordpress.org site. The minimum PHP version recommended by the wordpress.org website today is\u2026","rel":"","context":"In &quot;cPanel&quot;","block_context":{"text":"cPanel","link":"https:\/\/pixert.com\/blog\/category\/cpanel\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2021\/02\/5F407661-812C-4399-AD7D-85161B0A72B3.jpeg?fit=1200%2C363&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2021\/02\/5F407661-812C-4399-AD7D-85161B0A72B3.jpeg?fit=1200%2C363&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2021\/02\/5F407661-812C-4399-AD7D-85161B0A72B3.jpeg?fit=1200%2C363&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2021\/02\/5F407661-812C-4399-AD7D-85161B0A72B3.jpeg?fit=1200%2C363&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2021\/02\/5F407661-812C-4399-AD7D-85161B0A72B3.jpeg?fit=1200%2C363&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":261,"url":"https:\/\/pixert.com\/blog\/cropping-post-featured-thumbnails-from-top-instead-of-center-in-wordpress-with-native-cropping-tool\/","url_meta":{"origin":229,"position":5},"title":"Cropping Post Thumbnails from Top instead of Center in WordPress","author":"Pixel Insert \/ Pixert","date":"October 14, 2012","format":false,"excerpt":"WordPress Posts \u00a0Thumbnails or Post Featured Images \u00a0is a theme feature introduced with Version 2.9. Thumbnail is an image that is chosen as the representative image for Posts, Pages or Custom Post Types. The display of this images is up to the theme. This is especially useful for \"magazine-style\" themes\u2026","rel":"","context":"In &quot;Code Snippet&quot;","block_context":{"text":"Code Snippet","link":"https:\/\/pixert.com\/blog\/category\/code-snippet\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/10\/feaimagewp-300x173.jpg?resize=350%2C200","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/posts\/229","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/comments?post=229"}],"version-history":[{"count":0,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/posts\/229\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/media\/232"}],"wp:attachment":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/media?parent=229"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/categories?post=229"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/tags?post=229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}