This article mainly introduces the ZF framework for use with the validator (custom calibrator and validator chain), need friends can refer to the following
Code as follows: <?php require_once ("zend/loader.php"); The introduction of the validator class and the function Class (INT) of the calibrator, and the custom interface class; Zend_loader::loadclass (' zend_validate '); Zend_loader::loadclass (' Zend_validate_int '); Zend_loader::loadclass (' Zend_validate_interface '); Add custom Validator Feature Class (gongbeinum) [Common multiple] class Gongbeinum implements Zend_validate_interface { //Declaration interface error message Reporting properties Protected $_messages = Array (); //the validation method in the interface public function IsValid ($num) { if (! $num%3==0) &&! ($num%5==0)) { //if the checksum fails, the error message returns the value to the error message report properties $this-> _messages[] = "The number you entered is not a common multiple of 3 and 5!" "; //terminating procedure return false; } //Back true return true; &NBSP} //The error method that defines the interface public function getmessages () { return $this-> _messages; } / /Definition Fetch error message (can not) public function geterrors () { &NBSP}}//class definition detection Common multiple method function Check_num ($num) { // Instantiate Validator class $Validate = new Zend_validate (); //Add Validator Feature class, add customThe function class of the validator, form the calibrator chain $Validate-> addvalidator (New Zend_validate_int ()) -> Addvalidator (new Gongbeinum ()); //Check parameter if (! $Validate-> isValid ($num)) { //If error loop error message and output foreach ($ Validate-> getmessages () as $value) { echo $value. "<br>"; return false; &NBSP}  } //Specify the value of the judgment $num 1 = ' 15 '; Run Check method Check_num ($num 1);?>