3

Hey I'm trying to detect if I am requesting a php website with an ipad. I know this should be possible with

if(stristr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {

but if I just echo my User agent I get this:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15(KHTML, like Gecko) Version/13.1.1 Safari/605.1.15

I know there are many classes etc. to detect that like mobiledetect.. but they are all using the User agent and mine has no ipad in. So what am I doing wrong?

2 Answers2

3

Unfortunately, as of right now, this is no longer possible. This is due to Apple making changes to create "Desktop-Class Browsing with Safari", where, on iPadOS, users are presented with the Desktop version of a website. There isn't anything in the user agent anymore that will allow for distinguishing between the iPad and Desktop.

TJBeanz
  • 146
  • 5
0

Since you understand how to use PHP:

How to detect iPad Pro as iPad using javascript?

Here is the Javascript equivalent with a lot of answers. You will have no problem to copy them to PHP.

ChrisG
  • 202
  • 2
  • 13