<?
$str = "中国";
echo $str;
echo "<hr>";//if (preg_match("/^[".chr(0xa1)."-".chr(0xff)."]+$/", $str)) { //只能在GB2312情况下使用
if (preg_match("/^[\x7f-\xff]+$|^[a-zA-z ]+$/", $str)) { //兼容gb2312,utf-8
echo "正确输入";
} else {
echo "错误输入";
}
?>参考资料 http://www.web1357.cn/post/php_regex_chinese.html
$str = "中国";
echo $str;
echo "<hr>";//if (preg_match("/^[".chr(0xa1)."-".chr(0xff)."]+$/", $str)) { //只能在GB2312情况下使用
if (preg_match("/^[\x7f-\xff]+$|^[a-zA-z ]+$/", $str)) { //兼容gb2312,utf-8
echo "正确输入";
} else {
echo "错误输入";
}
?>参考资料 http://www.web1357.cn/post/php_regex_chinese.html
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货