Home >php教程 >php手册 >PHP源码学习:站内搜索HTML版

PHP源码学习:站内搜索HTML版

WBOY
WBOYOriginal
2016-06-21 08:58:36794browse
//require("config.inc.php"); 

function get_msg($path) { 
global $key, $i; 
$handle = opendir($path); 
while ($filename = readdir($handle)) { 
//echo $path."/".$filename."
"; 
$newpath = $path."/".$filename; 
$check_type = preg_match("/\.html?$/", $filename); 
if (is_file($newpath) && $check_type) { 
$fp = fopen($newpath, "r"); 
$msg = fread($fp, filesize($newpath)); 
fclose($fp); 
match_show($key, $msg, $newpath, $filename); 

if (is_dir($path."/".$filename) && ($filename != ".") &&  ($filename != "..")) { 
//echo "


".$newpath."


"; 
get_msg($path."/".$filename); 


closedir($handle); 
return $i; 


function match_show($key, $msg, $newpath, $filename) { 
global $key, $i; 
$key = chop($key); 
if ($key) { 
$msg = preg_replace("/



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn