我最近開始使用PHP,我試圖加載一個網站的內容,其中包含(.txt)格式的文件名列表。另外,我創建了一個函數:PHP代碼無法正常工作
<?php
//--------------------------
// The function itself
//--------------------------
function LoadSource($siteurl) {
$arrText = file($siteurl);
for ($i=0; $i<count($arrText); $i++) {
$pos = strpos($text . $arrText[$i], "+CUSERR+");
if ($pos !== false) {
echo "The string +CUSERR+ was found in the string";
$text = $text . $arrText[$i]." ==> REJECTED";
} else {
echo "The string +CUSERR+ was not found in the string";
$text = $text . $arrText[$i]." ==> ACCEPTED";
}
}
return $text;
}
$source = loadSource("http://www.example.com");
echo $source;
?>
什麼,我試圖做的是,首先該網站的那旁邊有它或(接受)(CUSERR)字txt文件名的內容,然後顯示(拒絕)加載TXT旁具有(CUSACK)字的文件名。
例子:
網址:www.example.com
內容:
file1.txt Rejected file2.txt Accepted
出了什麼問題? – 2011-06-13 18:30:13
這段代碼甚至不會執行,因爲我不知道你在做什麼循環,但它甚至從來沒有關閉。 – BraedenP 2011-06-13 18:32:50
也是「完美的xD」使用函數loadSource不是LoadSource ..然後我同意Braeden,這個代碼是不完整的.. – 2015-05-30 12:25:42