PHP username verification must be within 5 to 15 characters, and can only be letters, numbers, and underscores
PHP username verification must be within 5 to 15 characters, and can only be letters, numbers, and underscores
You can use regular verification, refer to the following
<code>/** * description 用户名验证 */ final public static function isName($val) { try { $pattem = "/^[a-zA-Z0-9_]{5,15}$/"; if (preg_match ( $pattem, $val )) { return $val; } else { return false; } } catch ( Exception $e ) { throw $e; } }</code>
Regular Expressions
<code>(\w|\d){5,15}/u</code>
In fact, all regular rules can be used universally~ It’s just that the calling method is different~ The rules I wrote in Swift are the same as those written in the front end, but the final judgment method of calling is different~