有人可以帮帮忙吗?如何修改它只允许a-Z,0-9? 感谢。
if (preg_match('~[<>&"\'=\\\]~', preg_replace('~&#(?:\\d{1,7}|x[0-9a-fA-F]{1,6});~', '', $context['checked_username'])) != 0 || $context['checked_username'] == '_' || $context['checked_username'] == '|' || strpos($context['checked_username'], '[code') !== false || strpos($context['checked_username'], '[/code') !== false) $context['valid_username'] = false;
答案 0 :(得分:0)
以下代码检查[[:alnum:]](alnum
代表字母数字)
if (!preg_match("/^[[:alnum:]]+$/", $context['checked_username']))
{
$context['valid_username'] = false;
}