<?php header('Content-type:text/html; charset=utf-8'); $str = '你好'; if(preg_match('/^[\x{4e00}-\x{9fa5}]+$/u', $str)>0){ echo '全是中文'; }elseif(preg_match('/[\x{4e00}-\x{9fa5}]/u', $str)>0){ echo '含有中文'; } ?>
<?php header('Content-type:text/html; charset=utf-8'); $str = '你好'; if(preg_match('/^[\x{4e00}-\x{9fa5}]+$/u', $str)>0){ echo '全是中文'; }elseif(preg_match('/[\x{4e00}-\x{9fa5}]/u', $str)>0){ echo '含有中文'; } ?>
转载于:https://www.cnblogs.com/88phper/p/8651548.html