

|
Login to use this feature.
|
![]() Sep 26th, 2008
1
Regular expressions can be slow, have you benchmarked these functions?
function valid_name ($username)
{
return preg_match("#^[a-z][da-z_]{6,22}[a-zd]$#i", $username);
}
could be rewritten to something like:
function valid_name ($username)
{
if (isset($username[7]) && !isset($username[24] && $username[0] !== '_' && $username[strlen($username)] !== '_')
{
$username = str_replace($username, '_', '');
return ctype_alpha($username);
}
return false;
}
Note: this is just an example, I have not tested it nor have it benchmarked is. It could however be quicker. Especially with those complex regular expressions you have.![]() |
January 3rd, 2012
Pixel2Life's new Facebook page!
December 23rd, 2011
Our TOP members! Special thanks to Donna, 13lueMage, Jaymz, Rc69, Jamie Huskisson, Bug... and all our most active members.
December 21st, 2011
Should P2L Tutorials have a "Tagging" system?
December 15th, 2011
Want to suggest a new category or a new feature on Pixel2life?
December 13th, 2011
Improvements in the Forums
|















