有没有办法从Zend_Filter_Input输出过滤后的数据?

时间:2009-07-23 10:00:38

标签: php zend-framework

有没有办法输出Zend_Filter_Input类的所有过滤数据?

2 个答案:

答案 0 :(得分:3)

Zend_Filter_Input提供了许多方法来检索过滤和验证的数据。 首先,您可以检索所有字段的关联数组:

$data = $input->getEscaped(); // Retrieve all data, escaped with Zend_Filter_HtmlEntities
$data = $input->getUnescaped(); // Retrieve all data, not escaped.

您还可以获取某些数据段的关联数组,方法名称非常明确:

  $invalidFields = $input->getInvalid(); // Fields that failed validation

  $missingFields = $input->getMissing(); // Fields that were declared as 'required' using the 'presence' metacommand, but not in the input

  $unknownFields = $input->getUnknown(); // Fields that were not declared in the validator rules, but were present in the input.

最重要的是,Zend_Filter_Input通过__get魔术方法的实现提供了一个对象访问器:

$oneField = $input->oneFieldName

答案 1 :(得分:-1)

在表单中,您可以获得未经过滤的值。检查手册;)