Problems with the Windows version of XAMPP, questions, comments, and anything related.
by TgaWookie » 09. October 2014 11:21
I am trying to write data to a text file using php. After each line I am adding "\r\n" to the end of it, but when I open the file it only contains the "\n" at the end of the line so windows notepad shows all data on just one line. I have run the exact same files on USBWebserver and it works fine. Why is XAMPP changing the end of line characters? and how do I stop it happening?
-
TgaWookie
-
- Posts: 1
- Joined: 09. October 2014 11:05
- Operating System: Windows 7 x64
by JJ_Tagy » 09. October 2014 12:04
First, I recommend dumping windows notepad and go for something like Notepad++. Then you will see that XAMPP does not change anything as you can turn on the formatting view.
I have no issues getting this to work. Perhaps you should share your code.
- Code: Select all
<?php
$file = fopen("test.txt", "w");
echo fwrite($file, "Hello World. Testing!\r\n");
echo fwrite($file, "This is line two.");
fclose($file);
?>
Output:
- Code: Select all
Hello World. Testing!
This is line two.
-
JJ_Tagy
-
- Posts: 788
- Joined: 30. January 2012 13:44
- XAMPP version: 5.5.15
- Operating System: Windows 10 Pro x64
Return to XAMPP for Windows
Who is online
Users browsing this forum: No registered users and 160 guests