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 "字符串不包含中文";
}