GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Friday, April 15, 2011

Zend - Validation

To validate an input, use Zend_Validate class and an implementation of the class that use it:

require_once "Zend/Validate.php";
require_once "Zend/Validate/StringLength.php";

$validator = new Zend_Validate_StringLength(5);
$input = "Coming Here";

if($validator->isValid($input)){
     // success code
}else{
     // error code
     echo current($validator->getMessages());
}
Share/Bookmark

No comments:

Post a Comment