Jump to content

fopen linbreak


thibo1025

Recommended Posts

How can I make a line break appear in an external sheet (for example page.htm) using fopen as this way?

<?phpfopen("page.htm", 'a') or die("can't open file");$txt = $one.$br.$two;$one = "line one";$br = /* what shall I put here */;$two = "line two";fwrite($fh, $txt);fclose($fh);?>

Thx.

Link to comment
Share on other sites

To create a new line in the file, use \n or \r\nIn the file, it should create a new line, as the example shown:

$myFile = "testFile.txt";$fh = fopen($myFile, 'w') or die("can't open file");$string = "Testing Test\n";fwrite($fh, $string);$string2 = "Tutty Tut\n";fwrite($fh, $string2);fclose($fh);

Should come out like:

Testing TestTutty Tut

EDIT: Skym beat me to it. :) Always when I'm writing...

Link to comment
Share on other sites

oooohhhh sry I actually messed up I did /n instead of \nthx for

Link to comment
Share on other sites

Also, you need to switch the order of these lines:

$txt = $one.$br.$two;$one = "line one";$br = /* what shall I put here */;$two = "line two";

to this:

$one = "line one";$br = /* what shall I put here */;$two = "line two";$txt = $one.$br.$two;

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...