.txtファイルから読み込んでWebページに表示できるコードを書いています。
最初のコードに問題がありました。テキストが読み込まれ、ドキュメントにあるものがすべて消去されるという点でした。
私の元のコード:
function readIn(){
$input = fopen("input.txt", "r"); //Open the file, save opened file in input
$line = fgets($input);
fclose($input);
return $line
}
それは、すべての行を通過するためにWhileループを挿入したときにのみ機能し始めました
function readIn(){
$input = fopen("input.txt", "r"); //Open the file, save opened file in input
$fullText = ""; //Variable full text
while(!feof($input)){
$line = fgets($input);
$fullText = $fullText . $line;
}
fclose($input);
return $fullText;
}
echo readIn();