PHP判断是中文还是英文,_PHP教程

WBOY
发布: 2016-07-13 09:54:32
原创
1081 人浏览过

PHP判断是中文还是英文,

<span>static</span> <span>function</span> ischinese(<span>$s</span><span>){
 
        </span><span>$allen</span> = <span>preg_match</span>("/^[^/x80-/xff]+$/", <span>$s</span>);   <span>//</span><span>判断是否是英文</span>
        <span>$allcn</span> = <span>preg_match</span>("/^[".<span>chr</span>(0xa1)."-".<span>chr</span>(0xff)."]+$/",<span>$s</span>);  <span>//</span><span>判断是否是中文</span>
        <span>if</span>(<span>$allen</span><span>){  
              </span><span>return</span> 'allen'<span>;  
        }</span><span>else</span><span>{  
              </span><span>if</span>(<span>$allcn</span><span>){  
                   </span><span>return</span> 'allcn'<span>;  
              }</span><span>else</span><span>{  
                   </span><span>return</span> 'encn'<span>;  
              }  
        }  
               
   }</span>
登录后复制

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/996655.htmlTechArticlePHP判断是中文还是英文, static function ischinese( $s ){ $allen = preg_match ("/^[^/x80-/xff]+$/", $s ); // 判断是否是英文 $allcn = preg_match ("/^[". chr (0xa1)."...
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板