How do I detect Mobile Safari server side using PHP?

后端 未结 6 1903
深忆病人
深忆病人 2020-12-19 04:32

Mobile Safari is a very capable browser, and it can handle my website as it is perfectly. However, there are a few elements on my page that could be optimized for browsing u

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-19 05:11

    Mozilla/5.0 (webOS/1.0; U; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/1.0 Safari/525.27.1 Pre/1.0 that is the browser for the palm Pre, and the word 'Mobile' is not there.

    I am working on making my detect work fully with all newer capable browsers. After looking at the mytouch, G1, Palm Pre, droid and others, (but not all) I am now confident this is workable for all new phones:

    if(preg_match("/applewebkit/i", $_SERVER['HTTP_USER_AGENT']) && preg_match("/(mobile|pre)/i", $_SERVER['HTTP_USER_AGENT'])) header("Location: http://simplefoodie.com/iphone/?carryover=".urlencode($_SERVER[REQUEST_URI]));

提交回复
热议问题