Page 1 of 1

entering newline character in text file when using fgets()

Posted: Tue Dec 09, 2008 10:21 pm
by fairyprincess18
i'm using the fgets() function to open, read, and print the contents a text file.

here's my code:

Code: Select all

 
$handle = fopen("TVeedahl, Resume.txt", "r");
if ($handle) {
 while (!feof($handle)) {
 $buffer = fgets($handle, 4096);
 echo $buffer;
}
fclose($handle);
}
 
i'd really just like to clarify what and where to put newline characters in my text file so fgets() will recognize them

thanks.

Re: entering newline character in text file when using fgets()

Posted: Tue Dec 09, 2008 10:51 pm
by requinix
fgets reads until it finds the end of a line (or it hits the 4K-characters limit, or the end of the file). I guess I don't know what you mean by "recognize them".

If all you want is to print out the file just use readfile.