We usually using strlen() function to check the string size. The fast way to checking string size is using isset().

Code:
if (strlen($str) <>
echo ‘String must be at least 5 chars’;
}

if (!isset($str{5}))  {
echo ‘String must be at least 5 chars’;
}


isset() needs more little time than strlen() because isset() is construction language.