Home >Backend Development >PHP Tutorial >How does php determine whether it is an instance of isPhone and is_weixin?
protected function isPhone(){ $agent = strtolower($_SERVER['HTTP_USER_AGENT']); //pc请求头信息数组 $pc_arr=array('windows nt','macintosh','ipad','baiduspider','spider'); //如确认为移动端则更改默认值 //没找到pc数组元素时判断为移动端 foreach($pc_arr as $k => $v){ $pc=strpos($agent, $v) ? true : false; if($pc){ return false; } } return true; }
/** * 判断是否微信 * liangzheng 2014-12-03 */ protected function is_weixin(){ if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ) { return true; } return false; }
The above is the detailed content of How does php determine whether it is an instance of isPhone and is_weixin?. For more information, please follow other related articles on the PHP Chinese website!