Hello everyone. I am new to PHP (just started learning it yesterday), but it seems fairly easy (maybe because I am familiar with a few other programming languages). However, I have come upon a strange problem. In everything I have read about PHP, \n is a new line, or \r\n can work as well. However, it doesn't work for me. I am trying to write a text file on the server. When I use \n, it writes a strange character to the file. When I use \r\n, it does start a new line, but it also indents the new line, which I don't want. Here's the code I'm using:
Code: Select all
<html>
<body>
<?php
if (!($f=fopen("welcome.txt","a+"))) {
echo "Unable to open file!";
}
else {
if (!fwrite($f,"$id \r\n Hello")) {
echo "Unable to write information to PHP file.";
}
else {
echo "Done! Please click <a href='history.go(-1)'>here</a> to return to the previous page.";
}
fclose($f);
}
?>
</body>
</html>
the new line is in the fwrite part right above the "Unable to write information..." line. Am I doing something wrong, or is there no way to do this?
-IMP
*EDIT* The blue "are" at the top is supposed to be the letter "R" (lower-case), but the forums are replacing it.