当前位置: 动力学知识库 > 问答 > 编程问答 >

PHP :Fatal error using fwrite to append one file to the end of another

问题描述:

Hey Im trying to append one file to the end of another and then display to screen and have looked for a solution to my error and have been unsuccessful. The code below does work to add info from the second file onto the end of the other but will not display on screen and gives me a fatal error on line 13 , any help/guidance would be appreciated! Cheers.

<?php

$file1 = fopen("lab5.1", "a+") or exit("Unable to open file1!");

$file2 =fopen("lab5.2", "r+") or exit("Unable to open file2!");

while(!feof($file1)){

fwrite($file1 , fread($file2,100));

}

fclose($file1);//close and reopen added to try solve fatal error

$file1 = fopen("lab5.1", "r") or exit("Unable to open file1!");

while(!feof($file1))

{

echo fgets($file1). "<br>";

}

fclose($file1);

fclose($file2);

?>

分享给朋友:
您可能感兴趣的文章:
随机阅读: