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

Double filtering

When using two filters after each other you have to keep in mind that it is often not possible to get the original output by using the opposite filter. Take the following example:


// Attach a filter
$filter   = new Zend_Filter_Word_UnderscoreToCamelCase();
$filtered $filter->filter($original);

// Use it's opposite
$filter2  = new Zend_Filter_Word_CamelCaseToUnderscore();
$filtered $filter2->filter($filtered)

The above code example could lead to the impression that you will get the original output after the second filter has been applied. But thinking logically this is not the case. After applying the first filter my_original_content will be changed to MyOriginalContent. But after applying the second filter the result is My_Original_Content.

As you can see it is not always possible to get the original output by using a filter which seems to be the opposite. It depends on the filter and also on the given input.

Zend Framework