Generally, there are two types of codes: UTF8 and GBK. Therefore, there are two types of matching codes (see the code configured for your website). <? Php
$ Action = trim ($ _ GET ['action']);
If ($ action = "sub ")
{
$ Str = $ _ POST ['dir'];
// If (! Preg_match ("/^ [". chr (0xa1 ). "-". chr (0xff ). "A-Za-z0-9 _] + $/", $ str) // GB2312 Regular Expression of Chinese characters, letters, numbers, underscores (_)
If (! Preg_match ("/^ [\ x {4e00}-\ x {9fa5} A-Za-z0-9 _] + $/u", $ str) // UTF-8 Chinese characters, letters, numbers, underscores, regular expressions
{
Echo "<font color = red> The [". $ str. "] You entered contains illegal characters </font> ";
}
Else
{
Echo "<font color = green> The [". $ str. "] You entered is completely legal. Pass! </Font> ";
}
}
?>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.