Examples of using the zf framework validator _ PHP Tutorial

Source: Internet
Author: User
Examples of using the zf framework validator. This article describes how to use the zf framework validator (custom validator and validator chain). If you need it, refer to the following code :? Phprequire_once (ZendLoader. php); this article mainly introduces the use example of the zf framework validator (custom validator and validator chain). For more information, see

The code is as follows: _ Messages [] = "the value you entered is not a public multiple of 3 and 5! "; // Terminate the program return false;} // return true;} // define the interface's error method public function getMessages () {return $ this-> _ messages ;} // define extraction error message (optional) public function getErrors () {}}// out-of-class definition detection public multiple method function check_num ($ num) {// instantiate the validator class $ Validate = new Zend_Validate (); // add the validator function class and add the UDF class, form the validator chain $ Validate-> addValidator (new Zend_Validate_Int ()-> addValidator (new GongBeiNum (); // verify the parameter if (! $ Validate-> isValid ($ num) {// if an error loop error message is returned and foreach ($ Validate-> getMessages () as $ value) {echo $ value ."
"; Return false ;}}// specify the value to be judged $ num1 = '15'; // run the check_num ($ num1) verification method;?>

Refer (custom validator and validator chain). If you need a friend, refer to the following code :? Phprequire_once (Zend/Loader. php );/...

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.