Devolper12345
Devolper12345

Reputation: 81

How can I detect with php that the user uses an ipad when my user agent doesnt conatin something like that

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?

Upvotes: 5

Views: 2244

Answers (2)

TJBeanz
TJBeanz

Reputation: 156

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.

Upvotes: 3

ChrisG
ChrisG

Reputation: 202

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.

Upvotes: 0

Related Questions