Detect IPAD using php HTTP_USER_AGENT

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

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?

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

3 Likes

I want to fix image resize issue on IPAD.

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

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.

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

https://developer.mozilla.org/en-US/docs/Tools/Responsive_Design_Mode

Isn’t it something you can fix with CSS?

3 Likes

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