只允许汉字,字母,数字和下横线组合的正则
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
if(isset($_GET["username"])){
$username=$_GET["username"];
$str=mb_strlen($username);
if(!preg_match("/^[".chr(0xa1)."-".chr(0xff)." | a-z | 0-9 | A-Z| \_]+$/",$username) || $str16)
{
echo "1";
}
}
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
if(isset($_GET["username"])){
$username=$_GET["username"];
$str=mb_strlen($username);
if(!preg_match("/(([\xB0-\xF7][\xA1-\xFE])|([\x81-\xA0][\x40-\xFE])|([\xAA-\xFE][\x40-\xA0])|(\w))+/",$username) || $str16)
{
echo "1";
}
}
$s ='我是ss中_文';
$p='/^[\x{4e00}-\x{9fa5}\w]+$/u';
$bool=preg_match($p,$s);
var_dump($bool); // 1
<br><font color="#e78608">------解决方案--------------------</font><br>
你这是 gbk 编码的<br>if(preg_match('/^(?:\w|[\x80-\x9f\xb0-\xff].)+$/', $s))<br><br>对于 utf-8 编码要简单些<br>if(preg_match('^\w+$/u'))<br> <div class="clear">
</div>
Comment ouvrir le fichier VSD
Impossible de démarrer votre ordinateur normalement
Comment récupérer des fichiers supprimés définitivement sur un ordinateur
La différence entre le magasin phare autogéré de JD.com et son magasin phare officiel
Quel fichier est mydrivers
Comment changer le logiciel de langue C en chinois
Échange de Bitcoins
Refroidissement d'un ordinateur portable ASUS