約40〜50回連続して出力を繰り返して停止するPHP印刷ステートメントに問題があります。私はそれが1行だけを印刷することになっていたと思った。私はまだPHPに少し新しかったので、私が間違っていることを理解していません。問題のコードはスニペットの一番下にあります。事前にPHP繰り返し印刷ステートメント
おかげで.....
<?php
$query = $_POST['query'];
find_files('.');
function find_files($seed) {
if(! is_dir($seed)) return false;
$files = array();
$dirs = array($seed);
while(NULL !== ($dir = array_pop($dirs))) {
if($dh = opendir($dir)) {
while(false !== ($file = readdir($dh))) {
if($file == '.' || $file == '..') continue;
$path = $dir . '/' . $file;
if(is_dir($path)) {
$dirs[] = $path;
} else {
if(preg_match('/^.*\.(php[\d]?|js|txt)$/i', $path)) {
check_files($path);
}
}
}
closedir($dh);
}
}
}
function check_files($this_file) {
$query = $_POST['query'];
$str_to_find = $query;
if ((isset($str_to_find)) && (empty($str_to_find))) {
print '<p>Your search produced no results</p>';
} else {
if(!($content = file_get_contents($this_file))) {
echo("<p>Could not check $this_file</p>\n");
} else {
if(stristr($content, $str_to_find)) {
echo("<p>$this_file -> contains $str_to_find</p>\n");
}
}
unset($content);
}
}
?>
それは繰り返されている 'あなたの検索結果は生成されませんでしたか? – spencercw
はい、これは間違いです –
おそらく、あなたはCheckfilesを繰り返し呼び出すことになります(spencercwのヒント)? - > check_files($ path);それはwhile()ループにあるので、セクションがループするたびに出力されます。 – user978122