实例如下: /** * 判断当前访问的用户是 PC端 还是 手机端 返回true 为手机端 false 为PC 端 * @return boolean */ function isMobile(){ $useragent=isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; //echo $useragent;die; $useragent_commentsblock=preg_match('|\(.*?\)|',$useragent,$matches)>0?$matches[0]:''