|
Posted by rfhurley on 01/18/07 19:28
I used this script (even tried a cut 'n' paste):
// open file
$file = fopen("welcome.txt", "r");
// fetch contents of file (using filesize() to fetch the entire file
contents
$contents = fread($file, filesize($file));
// close file, since we don't need to read it further in this session
fclose($file);
// output contents
echo $contents;
this didn't work. And I tried (again, I tried it a second time, cutting
& pasting from your example):
echo file_read_contents("welcome.txt");
the "readfile()" example worked, although it ran all the lines into one
line. But finally I found the "fgets()" function (using the "feof()"
function to read line-by-line), and that printed out the text file the
way I wrote it. Is there some version-related caveat to the "contents"
functions that may affect whether they work or not over certain
servers?
Any 411 on that would be helpful.
Thanks again!
Rob
Kim André Akerø wrote:
>
> And as Rik also pointed out, you can do this in one shot using
> file_read_contents() or readfile():
>
> echo file_read_contents("welcome.txt");
>
> OR
>
> readfile("welcome.txt");
>
> --
> Kim André Akerø
> - kimandre@NOSPAMbetadome.com
> (remove NOSPAM to contact me directly)
[Back to original message]
|