我正在放在一起搜索引擎在PHP中循环了一些目录和回声滤波结果,因为它去了。回声页面,而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);
}
}
}
感谢
那么你还没有显示你的代码,这样就可以给出关于如何修改代码以在搜索过程中回显结果的建议。 – 2013-03-22 20:01:31
@MikeBrant代码添加。 – John 2013-03-22 20:11:42