Detect IPAD using php HTTP_USER_AGENT


#1

Hi,

I am trying to find device of the user on website.

I tried below solution but I am not getting success.

   $_SERVER['HTTP_USER_AGENT'];
        if(stristr($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit')) {
		    // probably an iPad
		//    echo " THis is IPAD Apple ";
	}
	$isiPad = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPad');

Both in browser and IPAD I see same values for HTTP_USER_AGENT

In Browser - Laptop
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36 OPR/52.0.2871.40

In Browser -IPAD
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36 OPR/52.0.2871.40

I am using http://mobiletest.me to check website on IPAD

Any idea?

Best Regards,
Shahab


#2

Have you tried it from an actual iPAD? A bit of a search suggests that you should be able to check whether the string "iPad" appears in the HTTP_USER_AGENT string, and if that site isn't providing, it suggests a problem with the site, unless a real iPAD does the same thing (the solution I found in a search was dated 2010, so maybe it's out of date).

It's weird that those two agent strings are identical if one is supposed to be emulating something else. What user-agent string do you get if you choose something entirely different?


#3

Dare I ask, why you are trying to check for an iPad?


#4

I want to fix image resize issue on IPAD.

I will check on firefox device option. I don't have IPAD for testing.


#5

There should be a mode in your web browser that allows you to resize your screen to certain size. Both Firefox and Chrome have this feature and they also have different sizes for different devices that are listed.


#6

Any idea about testing on IPAD. Alternative to mobiletest link I shared in previous post?


#7



#8

Isn't it something you can fix with CSS?


#9

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.