I want to check a for any illegal character using the following regular expression in PHP. Essentially, I want to allow only alphanumeric and underscore (_). Unfortunately the
If $username only has alphanumeric and underscore it will return TRUE
$username
if (preg_match("/^[a-z0-9_]+$/i", $username) ) { return true; }