Home  >  Article  >  Backend Development  >  Function to determine Chinese_PHP tutorial

Function to determine Chinese_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:00:111329browse

 


$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);

?>


www.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...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn