<?php
/**
 *判断字符串是否全是中文
 */
function isAllChinese($str){
    if(preg_match('/^[\x7f-\xff]+$/', $str)){
        return true;//全是中文
    }else{
        return false;//不全是中文
    }
}
 
var_dump(isAllChinese('你好'));
 
?>

来自微信公众号:编程社

PHP正则判断字符串是否全是中文

程序员日常进阶宝典,欢迎关注!

相关文章:

  • 2022-12-23
  • 2023-02-08
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
  • 2022-12-23
相关资源
相似解决方案