[分享] 可以幫我看看PHP程式碼哪裡錯嗎

看板PHP作者 (張小胖~)時間19年前 (2006/12/28 23:51), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
這是一個教學書上面的PHP程式碼 功能是搜尋引擎,搜尋網站裡面"VB"這個資料夾裡面的字串 我用來測試之後,發現有畫面,但是執行搜尋之後並沒有任何反應 程式碼我大概看的懂 ,不過不知道錯在哪 請PHP高手幫我看看哪裡有錯好嗎 謝謝 <? function EchoTitleAndHref( $Filename, $Title ) { If ( $Title == "" ) $Title = $Filename; echo "<LI><A HREF="$Filename">$Title</A><BR>"; } function SearchDir( $dir, $Keyword ) { // Part I: 搜尋檔案 $handle=opendir( $dir ); while ( $file = readdir($handle) ) { if ( is_file( "$dir/$file" ) ) { if ( strtolower(substr( "$dir/$file", -3 )) == "htm" ) { $fd = fopen("$dir/$file", "r" ); $content = fread( $fd, filesize("$dir/$file") ); $Y = strpos( $content, $Keyword ); if ( gettype($Y) == "integer" ) { $GLOBALS["count"] = $GLOBALS["count"] + 1; $Upcontent = strtoupper( $content ); $pos1 = strpos( $Upcontent, "<TITLE>" ); $pos2 = strpos( $Upcontent, "</TITLE>" ); $Title = ""; if ( $pos1 > 0 And $pos2 > 0 ) $Title = substr( $content, $pos1+7, $pos2 - $pos1 - 7 ); EchoTitleAndHref( "$dir/$file", $Title ); } } } } closedir($handle); // Part II: 遞迴搜尋子目錄 $handle=opendir( $dir ); while ( $sdir = readdir($handle) ) { if ( is_dir("$dir/$sdir") And $sdir <> "." And $sdir <> "..") { SearchDir( "$dir/$sdir", $Keyword ); } } closedir($handle); } ?> <HTML> <HEAD><TITLE>學 VB 找王國榮 -- 搜尋引擎</TITLE></HEAD> <BODY BGCOLOR=WHITE> <H2>學 VB 找王國榮 -- 搜尋引擎<HR></H2> <FORM Action=search.php Method=Get> 請輸入欲搜尋的字串: <INPUT Type=Text Name=Keyword Value="<?echo $Keyword;?>"> <INPUT Type=Submit Value="搜尋"> </FORM> <HR> <? if ( !empty($Keyword) ) { echo "<H3>搜尋 $Keyword 的結果:<HR></H3>"; echo "<UL>"; $count = 0; SearchDir( "vb", $Keyword ); if ( $count == 0 ) echo "<LI>沒有找到符合 "$Keyword" 的文件!"; echo "</UL><HR>"; } ?> </BODY></HTML> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.134.33.104
文章代碼(AID): #15a-W4Qi (PHP)
文章代碼(AID): #15a-W4Qi (PHP)