WAP 開發與 Web 開發差異較大,本文總結六大核心問題及對策。
<card> 內。header("Content-type: text/vnd.wap.wml; charset=\"utf-8\"");
建議統一 UTF-8,相容移動/聯通雙平台。User-Agent (UA) 識別裝置。class MobileInfo {
function getPhoneNumber() { /* 從 $_SERVER['HTTP_X_NETWORK_INFO'] 等解析 */ }
function getUA() { return $_SERVER['HTTP_USER_AGENT'] ?? false; }
function getPhoneType() { $ua=$this->getUA(); return $ua?explode(' ',$ua)[0]:false; }
function isOpera() { return $this->getUA() && preg_match('/Opera/i',$this->getUA()); }
function isM3gate() { return $this->getUA() && preg_match('/M3Gate/i',$this->getUA()); }
function getHttpAccept() { return $_SERVER['HTTP_ACCEPT'] ?? false; }
function getIP() { $ip=getenv('REMOTE_ADDR'); $fwd=getenv('HTTP_X_FORWARDED_FOR'); return ($fwd && $fwd!='unknown')?$fwd:$ip; }
}
<card> 內,<p> 分段。掌握這六點,能有效規避 WAP 開發常見坑點。