This article mainly introduces the ZF Framework filter filter Use example, the code has comments, the need for friends can refer to the following
Code as follows: <?php/* Filter Simple use method and operation () * * require_once ("zend/loader.php"); The string that introduces Filter to lowercase class and capitalization class Zend_loader::loadclass ("Zend_filter_stringtolower"); Zend_loader::loadclass ("Zend_filter_stringtoupper"); Instantiate the string to lowercase class and capitalization class $Filter = new Zend_filter_stringtolower (); $Filter 2 = new Zend_filter_stringtoupper (); Set the string to be converted $Temp = ' Zhouwujie Zhouwujie '; Conversion method Filter (); $Result = $Filter-> Filter ($Temp); $Result 2 = $Filter 2-> filter ($TEMP); Echo $Result; echo $Result 2?> code as follows: <?php/* Filter use method and operation (filter chain)/require_once ("zend/loader.php"); Filter filters are used to load filters and filter the method class Zend_loader::loadclass ("Zend_filter"); Zend_loader::loadclass ("Zend_filter_htmlentities"); Zend_loader::loadclass ("Zend_filter_striptags"); After instantiating the filter, add the filter addfilter (new Filter Method class name ()) $Filter = new Zend_filter (); $Filter//-> addfilter (New Zend_filter_htmlentities ()); -> addfilter (New Zend_filter_striptags ()); $String = "<a href= ' # ' > Link </a>"; $Result = $Filter-> Filter ($String); echo $Result?> code as follows: <?php/* Custom Filter/require_once ("zend/loader.php"); Zend_loader::loadclass ("Zend_filter_interface"); Class Myfilter implements Zend_filter_interface { public function Filter ($value) { $List = array (' Yellow ', ' Bet ', ' poison '); foreach ($List as $k => $v) { $value = Str_replace ($v, ' * ', $value); } R Eturn $value; &NBSP} $Filter = new Myfilter (); $String = ' This message is yellow content '; $String 2 = ' He went gambling today '; $String 3 = ' He went on drugs today '; echo "