Home > Article > Backend Development > Function to determine Chinese_PHP tutorial
$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);
?>