[SOLVED] Simple question about using fwrite()

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
joetheeskimo5
Forum Commoner
Posts: 43
Joined: Sun Dec 14, 2003 4:47 pm
Location: US
Contact:

[SOLVED] Simple question about using fwrite()

Post by joetheeskimo5 »

How can I do a line break while writing to a file with fwrite()? I tried using the \n symbol, but it generated parse errors. Can anyone help?

Thanks!
Joe
Last edited by joetheeskimo5 on Sun Apr 18, 2004 12:05 pm, edited 1 time in total.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

fwrite($fp, "\n\r"); should work fine. What is the error you get?
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

if your are using single quotes, use double:
$content = "tim \n tim \n";
below wouldnt work:
$content = 'tim \n tim';

also try: \r\n
joetheeskimo5
Forum Commoner
Posts: 43
Joined: Sun Dec 14, 2003 4:47 pm
Location: US
Contact:

Post by joetheeskimo5 »

Ohh, my problem was that I didn't you know you could put the \n straight into the quotes, i did it like this:

"Blah".\n."blah"

When I should have done:

"Blah \n Blah"

Thanks! :)

~Joe
Post Reply