首頁  >  文章  >  後端開發  >  PHP判断是中文还是英文,_PHP教程

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

WBOY
WBOY原創
2016-07-13 09:54:321084瀏覽

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)."...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn