还是php验证中文的问题

来源:互联网 发布:怎样注册开淘宝网店 编辑:程序博客网 时间:2024/04/30 16:17

找了个这样的正则试试看

  1. /*判断字符串$str是否含有非法字符*/ 
  2. $str='朱镕基234大家sfdAHJ ̄s々 Ⅳ 4 N ぁ Ψ Ж ㄩ ā '
  3. function match_str($str
  4. {
  5.     preg_match_all('/[一-龥]|[/w/d]+/u'$str$matchs);
  6.     $new_str = implode("",$matchs[0]);
  7.     if (strlen($str) == strlen($new_str)) {
  8.         return 1;
  9.     }else{
  10.         return 0;
  11.     }
  12. echo match_str($str); 
原创粉丝点击