Copy Code 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");
Instantiating a string to a lowercase class and a 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;
?>
Copy Code code as follows:
<?php
/* Filter use method and operation (filter chain) * *
Require_once ("zend/loader.php");
Filter the filter chain of the use of load filter and filter method class
Zend_loader::loadclass ("Zend_filter");
Zend_loader::loadclass ("Zend_filter_htmlentities");
Zend_loader::loadclass ("Zend_filter_striptags");
Add filter addfilter After instantiating filter (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;
?>
Copy Code 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);
}
return $value;
}
}
$Filter = new Myfilter ();
$String = ' This message is yellow content ';
$String 2 = ' He went gambling today ';
$String 3 = ' He went on drugs today ';
echo "echo $Filter-> Filter ($String). "<br>";
echo $Filter-> Filter ($String 2). "<br>";
echo $Filter-> Filter ($String 3). "<br>";
?>