entering newline character in text file when using fgets()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fairyprincess18
Forum Newbie
Posts: 21
Joined: Sun Dec 07, 2008 8:54 pm

entering newline character in text file when using fgets()

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post 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.
Post Reply