Home >Backend Development >PHP Tutorial >Example of using the validator of zf framework_PHP tutorial
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 . "