在javascript中,要判断字符串是中文是很简单的。比如:
123456var
str =
"php编程"
;
if
(/^[\u4e00-\u9fa5]+$/.test(str)) {
alert(
"该字符串全部是中文"
);
}
else
{
alert(
"该字符串不全部是中文"
);
}
PHP正确匹配中文方式, “u" for utf-8 mode
123456$str =
"php编程"
;
if
(preg_match(
"/^[\x{4e00}-\x{9fa5}]+$/u"
,$str)) {
print(
"该字符串全部是中文"
);
}
else
{
print(
"该字符串不全部是中文"
);
}
I am a common boy from China... The blog will record my life, my happiness and my sorrow and whatever. It is really good place to share with you, my love and my friends. Now I am a husband, my wife is called Yuxia, a sweety girl. I am a father of two boys, weiheng and weibo. Grow up day by day!
Ubuntu 10.10 Pentax K-5
Saturday, December 02, 2017
regex 中文
Tuesday, November 28, 2017
QRCode Generator in Php
phpqrcode http://phpqrcode.sourceforge.net/ can be used to generate qrcode in php.
It supports to generate the code and save to external file or export to browser.
It supports to generate the code and save to external file or export to browser.
ob_start();\PHPQRCode\QRcode::png('http://www.chatcai.tk/player-chatroom/register?code='.$model->invitation_code, null, 'L', 4, 2);$imageString = base64_encode( ob_get_contents() );ob_end_clean();
Subscribe to:
Posts (Atom)