Home  >  Article  >  Backend Development  >  PHP validate data validation

PHP validate data validation

不言
不言Original
2018-04-13 16:57:535619browse

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 = [
        &#39;name&#39; => &#39;require|max:10&#39;,
        &#39;password&#39; => [
            &#39;require&#39;,
            &#39;regex&#39; => &#39;/^([0-9]|[a-zA-Z]){6,18}$/i&#39;,
        ],
    ];

    // 定义提示语(自定义)
    protected $message = [
        &#39;name.require&#39; => &#39;独立验证:姓名不能为空!&#39;,
        &#39;name.max&#39; => &#39;姓名的长度不超过10个字符&#39;,
        &#39;password.regex&#39; => &#39;密码格式不正确!&#39;,
    ];
}

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Bit operations in phpNext article:Bit operations in php