我正在整理一个搜索引擎在php中循环一些目录和回声过滤结果.
我的问题是,在所有搜索完成之前不会执行回显,导致页面保持空白,直到脚本完成.
这是正常的吗?如果是这样,我怎样才能在调用回声时显示搜索结果?
我也将最终将结果中的图像写入屏幕.可以通过同时利用客户端和服务器端来调用JS document.write函数来代替回应所有内容吗?
编辑:这是迭代的代码.我有一个标记系统,但此部分已被注释掉了...
function checkTags($dir, $search){
global $tag;
$filesInDir = array_map('strtolower', scandir($dir)); // lower case the files
$filterOut = array('.','..');
$filesInDir = array_diff($filesInDir, $filterOut); // get rid of the current '.' and parent '..' values
// print_r($filesInDir);
foreach($filesInDir as $file) {
if($file == $tag) { // found a tag
echo 'found tag: '.$file.'<br>';
/* $tagDir = dirname($tag);
$tagContents = strtolower(file_get_contents($file).'<br>'.$tagDir); // adding full path to include parent dirs in tag searching
foreach($search as $s){
if(strpos($tagContents, $s) !== false){ // the tag has a search word
//getFiles($tagDir);
}
} */
}
elseif(is_dir($dir.'/'.$file) !== false) { //is a folder, so try in there
//print_r($file);
echo 'found dir: '.htmlspecialchars($file).'<br>';
checkTags($dir.'\\'.$file, $search);
}
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢