Zf frame Filter use example. Copy the code as follows :? Php * Simple usage and operation of the Filter () * require_once (ZendLoader. php); introduction of the Filter string to lowercase class and to the uppercase class Zend_Loader ::
The code is as follows:
/* Simple use and operation of the filter ()*/
Require_once ("Zend/Loader. php ");
// Convert the Filter string to lowercase or uppercase
Zend_Loader: loadClass ("Zend_Filter_StringToLower ");
Zend_Loader: loadClass ("Zend_Filter_StringToUpper ");
// Convert the instantiated string to lowercase or uppercase
$ Filter = new Zend_Filter_StringToLower ();
$ Filter2 = new Zend_Filter_StringToUpper ();
// Set the string to be converted
$ Temp = 'zhouwujie zhouwujie ';
// Conversion method filter ();
$ Result = $ Filter-> filter ($ Temp );
$ Result2 = $ Filter2-> filter ($ Temp );
Echo $ Result;
Echo $ Result2;
?>
The code is as follows:
/* Filter usage and operations (filter chain )*/
Require_once ("Zend/Loader. php ");
// Method class for loading filters and filters for the filter chain
Zend_Loader: loadClass ("Zend_Filter ");
Zend_Loader: loadClass ("Zend_Filter_Htmlentities ");
Zend_Loader: loadClass ("Zend_Filter_StripTags ");
// Add the filter addFilter (new filter method class name () after instantiating the filter ())
$ Filter = new Zend_Filter ();
$ Filter //-> addFilter (new Zend_Filter_Htmlentities ());
-> AddFilter (new Zend_Filter_StripTags ());
$ String = "link ";
$ Result = $ Filter-> filter ($ String );
Echo $ Result;
?>
The code is as follows:
/* 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 );
}
Return $ value;
}
}
$ Filter = new MyFilter ();
$ String = 'This message is yellow content ';
$ String2 = 'He has been gambling today ';
$ String3 = 'he is taking drugs today ';
Echo "filter content
";
Echo $ Filter-> filter ($ String )."
";
Echo $ Filter-> filter ($ String2 )."
";
Echo $ Filter-> filter ($ String3 )."
";
?>
The http://www.bkjia.com/PHPjc/741265.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/741265.htmlTechArticle code is as follows :? Php/* Simple usage and operations of filters () */require_once ("Zend/Loader. php "); // convert the string that introduces the Filter to lowercase and to Zend_Loader ::...