| 
<?php
/*
 *Author:beiliwenxiao
 *Description:It's very simple,Just a test.Please do not laugh at me.
 */
 class Filter
 {
 public $filename;
 public $check_text;
 public $check;
 
 function setFileName($filename)
 {
 $this->filename = $filename;
 }
 
 function setCheckText($check_text)
 {
 $this->check_text = $check_text;
 }
 
 function getCheck()
 {
 $fp=fopen($this->filename,"r");
 $this->check=0;
 while (!feof($fp))
 {
 $filter=fgets($fp);
 $filter=trim($filter);
 if(stristr($this->check_text,$filter))
 {
 $this->check=1;
 break ;
 }
 }
 fclose($fp);
 return $this->check;
 }
 
 }
 
 /*
 *example
 */
 $Filter= new Filter;
 $Filter->setFileName('filter_test.txt');
 $Filter->setCheckText('a');
 
 
 echo "IF you check_text in filter_test.txt <br />";
 echo "Like this:<br/>A<br/>ABC<br/>your words 1<br/>your words 2<br/>...<br/><br/>";
 echo "Search 'a' <br />";
 echo "It return:".$Filter->getCheck();
 echo "<br />";
 
 $Filter->setCheckText('b');
 echo "Search 'b' <br />";
 echo "It return:".$Filter->getCheck();
 echo "<br/><br/>IF you Check_text have 'a' Like 'Action'. <br />";
 
 $Filter->setCheckText('Action');
 
 echo "It return:".$Filter->getCheck();
 
 ?>
 |