PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Creating the Filter and Validator Processor

After declaring the filters and validators arrays, use them as arguments in the constructor of Zend_Filter_Input. This returns an object that knows all your filtering and validating rules, and you can use this object to process one or more sets of input data.

<?php
$input 
= new Zend_Filter_Input($filters$validators);

You can specify input data as the third constructor argument. The data structure is an associative array. The keys are field names, and the values are data values. The standard $_GET and $_POST superglobal variables in PHP are examples of this format. You can use either of these variables as input data for Zend_Filter_Input.

<?php
$data 
$_GET;

$input = new Zend_Filter_Input($filters$validators$data);

Alternatively, use the setData() method, passing an associative array of key/value pairs the same format as described above.

<?php
$input 
= new Zend_Filter_Input($filters$validators);
$input->setData($newData);

The setData() method redefines data in an existing Zend_Filter_Input object without changing the filtering and validation rules. Using this method, you can run the same rules against different sets of input data.

Zend Framework