thibo1025 Posted July 2, 2006 Share Posted July 2, 2006 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 More sharing options...
skym Posted July 2, 2006 Share Posted July 2, 2006 $br = "\n";or$br = "\r\n";for Windows systems. I always use \r\nSee http://www.php.net/manual/en/language.types.string.php for escaped characters. Link to comment Share on other sites More sharing options...
Flail-Meister Posted July 2, 2006 Share Posted July 2, 2006 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 More sharing options...
thibo1025 Posted July 2, 2006 Author Share Posted July 2, 2006 oooohhhh sry I actually messed up I did /n instead of \nthx for Link to comment Share on other sites More sharing options...
justsomeguy Posted July 3, 2006 Share Posted July 3, 2006 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now