Home > Backend Development > PHP Tutorial > Example of using the validator of zf framework_PHP tutorial

Example of using the validator of zf framework_PHP tutorial

WBOY
Release: 2016-07-13 10:35:52
Original
1206 people have browsed it

This article mainly introduces the use examples of the validator of the zf framework (custom validator and validator chain). Friends in need can refer to it

The code is as follows: _messages[] = "The value you entered is not a common multiple of 3 and 5!"; // Terminate the program return false; } //return true return true; } //Define the error reporting method of the interface public function getMessages() { return $this -> _messages; } //Define extraction error information (optional) public function getErrors() { ​ } } //Definition of common multiple detection method outside the class function check_num($num) { //Instantiate the validator class $Validate = new Zend_Validate(); //Add validator function class and add custom validator function class to form a validator chain $Validate -> addValidator(new Zend_Validate_Int()) -> addValidator(new GongBeiNum()); //Verification parameters if (!$Validate -> isValid($num)) { //If there is an error, loop the error message and output it foreach ($Validate -> getMessages() as $value) { echo $value . "
"; Return false; } } } ​ //Specify the value of judgment $num1 = '15'; //Run the verification method check_num($num1); ?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/741457.htmlTechArticleThis article mainly introduces the use examples of the validator of the zf framework (custom validator and verification Server chain), friends who need it can refer to the following code:?phprequire_once(Zend/Loader.php);/...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template