Home > Article > Backend Development > PHP validate data validation
The content shared with you in this article is about PHP validate data verification. It has certain reference value. Friends in need can refer to it
<?php namespace app\index\validate; use think\Validate; class User extends Validate { // 定义规则 protected $rule = [ 'name' => 'require|max:10', 'password' => [ 'require', 'regex' => '/^([0-9]|[a-zA-Z]){6,18}$/i', ], ]; // 定义提示语(自定义) protected $message = [ 'name.require' => '独立验证:姓名不能为空!', 'name.max' => '姓名的长度不超过10个字符', 'password.regex' => '密码格式不正确!', ]; }
Related recommendations:
Detailed explanation of jQuery validata plug-in example
The above is the detailed content of PHP validate data validation. For more information, please follow other related articles on the PHP Chinese website!