Home  >  Article  >  php教程  >  判断中文的函数

判断中文的函数

WBOY
WBOYOriginal
2016-06-13 11:16:281012browse

 


$a='english';

$b='中文';

$c='english&中文';



function chkGB($Str) {

$StrLen = strlen($Str);

$Length = 1;

for($i = 0;$i
$TmpStr = ord(substr($Str,$i,1));

$TmpStr2 = ord(substr($Str,$i 1,1));

if(($TmpStr =247) && ($TmpStr2 =247)) {

$LegalFlag = 0;

break;

}else {

$LegalFlag = 1;

}

}

return $LegalFlag;

}

echo chkGB($a).','.chkGB($b).','.chkGB($c);

?>


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
Previous article:常用表单验证类Next article:PHP自带函数大全