-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