Zend Framework implements the custom filter method, zendframework
This example describes how to implement a custom filter using Zend Framework. We will share this with you for your reference. The details are as follows:
Create a custom filter
Code:
<? Phprequire_once 'zend/Filter/Interface. php '; class MyFilter implements Zend_Filter_Interface {public function filter ($ value) {$ badlist = array ("Pear", "strawberry", "apple "); for ($ I = 0; $ I <count ($ badlist); $ I ++) {$ value = str_replace ($ badlist [$ I], "*", $ value) ;}return $ value ;}$ filter = new MyFilter (); $ temp1 = "Delicious oranges"; $ temp2 = "I like Apple "; $ temp3 = "nice pear, but my favorite dish is Strawberry! "; Echo" content :". $ temp1. "<p> after filtering:"; echo $ filter-> filter ($ temp1); echo "<p>"; echo "content :". $ temp2. "<p> after filtering:"; echo $ filter-> filter ($ temp2); echo "<p>"; echo "content :". $ temp3. "<p> after filtering:"; echo $ filter-> filter ($ temp3); echo "<p> ";
Result:
Content: oranges are delicious.
After filtering, the results show that the oranges are delicious.
Content: I like apple
After filtering: I like to eat *
Content: pear is also good, but my favorite food is Strawberry!
After filtering, it will be: * which is good, but what I like most is *!
Analysis:
The filter method is implemented after the interface is inherited. Then instantiate this class and call this method. You can complete the content you want to filter.