1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  2. <html xmlns="http://www.w3.org/1999/xhtml"> 
  3. <head> 
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  5. <meta http-equiv="p_w_picpathtoolbar" content="false" /> 
  6. <meta name="baidu-site-verification" content="JQiKjfbHRXKGMrk2" /> 
  7. <meta name="Copyright" content="Copyright www.lunanzuche.com All Rights Reserved." /> 
  8. <meta name="MSSmartTagsPreventParsing" content="true" /> 
  9. <meta name="author" content="MR newdomer" /> 
  10. <title>search results</title> 
  11. </head> 
  12. <body> 
  13. <?PHP 
  14. /** 
  15.  * s即表单提交来的参数 
  16.  **/ 
  17. $s = $_GET['s']; 
  18. $dir = substr($_SERVER["SCRIPT_FILENAME"],0,-10);//获取网站文件夹 
  19. $dir=opendir($dir);//Ŀ¼ 
  20. while(($file=readdir($dir))!==false){ 
  21.   
  22.  
  23.   
  24.    if($file!=="." && $file!==".." &&strpos($file,".")){ 
  25.         //ȡļ 
  26.         $c  = file_get_contents($file); 
  27.         //ƥǷؼ 
  28.         $s  = $s; 
  29.         $r  = "/\<title\>(.*)$s(.*)\<\/title\>/i"
  30.         if(preg_match($r,$c)){ 
  31.             $list[]=$file; 
  32.         } 
  33.         
  34.   
  35.    } 
  36.   
  37. if(empty($list)){ 
  38.     echo "no result"; 
  39. }else{ 
  40.     print_r($list); 
  41. //print_r(count($list)); 
  42.   
  43. closedir($dir); 
  44.  
  45.  
  46.  
  47. ?> 
  48.  
  49.  
  50. </body> 
  51. </html> 

此种方式只适用于小的网站,暂时没有分页功能