Skip to content

Instantly share code, notes, and snippets.

@fasthold
Created December 8, 2011 04:09
Show Gist options
  • Save fasthold/1446080 to your computer and use it in GitHub Desktop.
Save fasthold/1446080 to your computer and use it in GitHub Desktop.
有效的中文型用户名检测
function check_username($username) {
$guestexp = ‘\xA1\xA1|\xAC\xA3|^Guest|^\xD3\xCE\xBF\xCD|\xB9\x43\xAB\xC8′;
$len = $this->dstrlen($username);
if($len > 15 || $len < 3 || preg_match(“/\s+|^c:\\con\\con|[%,\*\"\s\<\>\&]|$guestexp/is”, $username)) {
return FALSE;
} else {
return TRUE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment