判断中文的函数_PHP教程
时间:2021-07-01 10:21:17
帮助过:5人阅读
$a='english';
$b='中文';
$c='english&中文';
function chkGB($Str) {
$StrLen = strlen($Str);
$Length = 1;
for($i = 0;$i < $StrLen;$i ) {
$TmpStr = ord(substr($Str,$i,1));
$TmpStr2 = ord(substr($Str,$i 1,1));
if(($TmpStr <= 161 || $TmpStr >=247) && ($TmpStr2 <= 161 || $TmpStr2 >=247)) {
$LegalFlag = 0;
break;
}else {
$LegalFlag = 1;
}
}
return $LegalFlag;
}
echo chkGB($a).','.chkGB($b).','.chkGB($c);
?>
http://www.bkjia.com/PHPjc/445536.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445536.htmlTechArticle$a=english; $b=中文; $c=english中文; function chkGB($Str) { $StrLen = strlen($Str); $Length = 1; for($i = 0;$i $StrLen;$i ) { $TmpStr = ord(substr($Str,$i,1)); $TmpStr2 = ord(s...