php判断字符串是英文还是中文【收藏】
static function ischinese($s){$allen = preg_match("/^[^\x80-\xff]+$/", $s); //判断是否是英文
$allcn = preg_match("/^[".chr(0xa1)."-".chr(0xff)."]+$/",$s);//判断是否是中文
if($allen){
return 'allen';
}else{
if($allcn){
return 'allcn';
}else{
return 'encn';
}
}
}
收藏自:http://stephenjqj.iteye.com/blog/516462
页:
[1]