function 判断字符串中是否有中文汉字,判断字符串是否全部为中文汉字

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_31617637/article/details/82803998
<?php
$str = '若你安好111便是晴天';
if (preg_match('/^[\x{4e00}-\x{9fa5}]+$/u', $str)>0) {
    echo '全是中文';
} else if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $str)>0) {
    echo '含有中文';
} else {
    echo '没有包含中文';
}
?>

猜你喜欢

转载自blog.csdn.net/qq_31617637/article/details/82803998