我正在尝试根据访问者的 UserAgent 字符串来识别他们的电话类型。但是,我在我的代码中找不到错误。
<?php
//create an array to be filled with phone type
$arr = phones();
$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
$palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS");
$berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");
$ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
$nokia = strpos($_SERVER['HTTP_USER_AGENT'],"Nokia");
if ($iphone || $android || $palmpre || $ipod || $berry || $nokia == true)
{
echo "Specially for you as $iphone owner!";
}
?>