-1
我在下面的代碼中更新了文本文件上的一行。解析文本文件更新行中的錯誤108
$filename = "flat-file-data.txt"; // File which holds all data
$rowToUpdate = 1; // This is line need to be updated
$newString = "This text is updated\n"; // This is what you want to replace it with
$arrFp = file($filename); // Open the data file as an array
// Replace the current element in array which needs to be updated with new string
$arrFp[$rowToUpdate-1] = $newString;
$numLines = count($arrFp); // Count the elements in the array
$fp = fopen($filename, "w"); // Open the file for writing
for($i=0; $i<$numLines; $i++) // Overwrite the existing content
{
fwrite($fp, $arrFp[$i]);
}
fclose($fp); // Close the file
但不幸的是我得到一個錯誤說 「解析錯誤:語法錯誤,意外 ';',在d預計 ')':\ PROGRAM FILES \ WAMP \ WWW \ mindandsoul \ processor.php 108上的」 。假設它意味着什麼?我如何擺脫它?任何方式來解決這個錯誤?
問題是你剛纔複製並可能粘貼代碼一個在線教程,無需查看粘貼的代碼! – Alireza