Examples of common rules for YII rules, yiirules example _php tutorial

Source: Internet
Author: User
Tags configuration php getting started with php smarty template yii

Examples of common rules for YII rules, yiirules example


This paper describes the rules commonly used in Yii rule. Share to everyone for your reference, as follows:

Public Function rules () {return array (//must be filled in with array (' email, username, Password,agree,verifypassword,verifycode ', ' r Equired '),//Check whether the user name repeats array (' email ', ' unique ', ' message ' = ' user name is occupied '),//user input maximum character limit array (' email, username ', ' Length ', ' Max ' =>64),//limit user minimum length and maximum length of array (' username ', ' length ', ' Max ' =>7, ' min ' =>2, ' toolong ' + ' username Please enter Length is 4-14 characters ', ' tooshort ' + ' user name please input length of 2-7 words '),//Limit password minimum length and maximum length of array (' password ', ' length ', ' Max ' =>22, ' min ' =>6 , ' toolong ' + ' password Please enter a length of 6-22 characters ', ' tooshort ' and ' = ' password Please enter a length of 6-22 characters '),//Determine whether the user input is the Mail array (' email ', ' email ', ' Message ' = ' = ' Mail format error '),//Check whether the password entered by the user is the same as the array (' VerifyPassword ', ' compare ', ' compareattribute ' = ' password ', ' Me Ssage ' = ' + ' Please enter the confirmation password '),//Check whether the user agrees to the terms of the agreement array (' agree ', ' required ', ' Requiredvalue ' =>true, ' message ' = ') Please confirm whether you agree to the terms of the Privacy Policy '),//Determine if the date format is array (' created ', ' Date ', ' format ' = ' yyyy/mm/dd/hh:mm:ss '),//Determine if the input characters are included in arr Ay (' superuser ', ' in ', ' range ' = = Array (0, 1)),//Regular Authenticator: Array (' name ', ' match ', ' pattern ' = '/^[a-z0-9\-_]+$/'),//Digital Authenticator: Array (' ID ', ' numerical ', ' min ' =>1, ' Max ' =>10, ' integeronly ' =>true),//type validation integer,float,string,array,date,time,datetime array (' Created ', ' type ', ' datetime '),//file Validation: Array (' filename ', ' file ', ' AllowEmpty ' =>true, ' types ' = ' zip, rar, xls, PDF, pp T ', ' toolarge ' + ' picture not more than 800K '), array (' URL ', ' file ',//defined as file type ' AllowEmpty ' =>true, ' type s ' = ' jpg,png,gif,doc,docx,pdf,xls,xlsx,zip,rar,ppt,pptx ',//upload file type ' maxSize ' =>1024*1024*10,//upload size limit, note not p Hp.ini upload file Size ' toolarge ' + ' file is larger than 10M, upload failed! Please upload files less than 10M! '), $news = new News (' Search '); Search Association Rules

Turn from: Small Talk blog http://www.tantengvip.com/2015/05/yii-rules/

For more information on YII related content readers can view this site topic: "YII framework Introduction and common skills Summary", "PHP Excellent Development Framework Summary", "Smarty Template Primer Basic Tutorial", "PHP date and Time usage summary", "PHP object-oriented Programming introduction Tutorial", " PHP String Usage Summary, "Getting Started with Php+mysql database operations" and "PHP Common Database Operations Skills Summary"

It is hoped that this article is helpful to the PHP program design based on YII framework.

Articles you may be interested in:

    • PHP YII Framework Development Little tricks Model (models) Rules custom validation rule
    • Nginx configuration PHP Rewrite rules example of Yii and cakephp framework
    • How to install the Yii framework using composer
    • Yii method for executing SQL statements using the Migrate command
    • Yii Framework framework uses YIIC to quickly create migrate usage examples of YII applications
    • Yii Framework Framework tutorial using YIIC quickly create a detailed application of Yii
    • The internationalization realization method of YII Framework frame Tutorial
    • A detailed description of the caching usage of YII Framework Framework Tutorial
    • A detailed description of the security scheme for YII Framework Framework Tutorial
    • A detailed description of the log usage of YII Framework Framework Tutorial
    • An explanation of the exception handling of YII Framework Tutorial

http://www.bkjia.com/PHPjc/1110073.html www.bkjia.com true http://www.bkjia.com/PHPjc/1110073.html techarticle example of common rules for yii rules, yiirules example This article describes the rules commonly used in Yii rules. Share to everyone for your reference, as follows: Public function rules () {return array (// required ...)

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.