0

How to detect iOS version with php. I am trying to work with the solution $_SERVER['HTTP_USER_AGENT'] but it display:

Mozilla/5.0 (iPhone; U; CPU iPhone OS 8_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7

I want to display OS 8_0 only.

Any help would be appreciated.

1

1 Answer 1

0

As you mention you have use $_SERVER['HTTP_USER_AGENT']

So output is

Mozilla/5.0 (iPhone; U; CPU iPhone OS 8_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7

In above output is contains the version of that(see bold text on above)

if (strpos($_SERVER['HTTP_USER_AGENT'], 'OS 8_0') !== false) 
{
    echo "This is iOS 8";
}
else{
    echo "This is not iOS 8";}
}

Read - Detecting iOS Version Number from User Agent using Regular Expressions

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.