what does "\n" and "\r" mean?
(i can't find documentation anywhere)
thanks.
the simplest of all questions
\n means line feed or return and \r means carraige return. Both terms that are easy to explain as printer functions. the \r returns the print head to the start of the line and the \n advances the paper reads for the next line of print.
Mark.
Mark,
thanks for the response...so why are they used in php code?
while they don't display on HTML, they can be used to space text in form boxes and in the source of HTML code.
They are used to mark the end of a line in a text file. or to make html code more readable. try writing a php script that creates a large webpage without them and it all tends to be on one line.
i.e. try running this
<?php
for ( $loop=0; $loop<100; $loop++ )
{
echo "number is ".$loop."<BR>";
}
?>
on screen the page looks fine but if you do a view source is just runs on one line. But if you stick \n after the <BR> the source is a lot easier to read. Ok poor example but it does show what I mean.
the \r is needed by windows. I had problems with a file written on a unix system when it was transfered to a windows machine because of the missing \r
I Hope that explains it.
Mark.
mark,
great example, thanks.
another simple question...
in your code why is ".$loop." in quotes with the dots?
It's just a habit I'm afraid. You can write the code as
echo "number is $loop <BR>";
but I just like the idea of having variables outside of fixed strings. What it does is end the string "number is " and then joins the loop variable onto it and then joins a further string "<BR>" on to that. Its something I picked up from writting unix shell scripts.
i get it...thanks so much for your help.