|  | Posted by Kim Andrι Akerψ on 01/18/07 22:54 
rfhurley wrote:
 > 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!
 
 If you're outputting this to a HTML page, you might want to do this:
 
 echo nl2br(file_read_contents("welcome.txt"));
 
 --
 Kim AndrΓ© AkerΓΈ
 - kimandre@NOSPAMbetadome.com
 (remove NOSPAM to contact me directly)
 [Back to original message] |