function hasChinese($str) {
return preg_match('/[\x{4e00}-\x{9fa5}]/u', $str);
}
// 使用示例
$string = "Hello 你好";
if (hasChinese($string)) {
echo "字符串包含中文";
} else {
echo "字符串不包含中文";
}
每天进步一点点
深耕网站建设与运营推广的一线实战洞察。
function hasChinese($str) {
return preg_match('/[\x{4e00}-\x{9fa5}]/u', $str);
}
// 使用示例
$string = "Hello 你好";
if (hasChinese($string)) {
echo "字符串包含中文";
} else {
echo "字符串不包含中文";
}