I was just experimenting with PHP dates and found most of the following code on the php site:
<?php
echo strtotime ("+1 day"),"\n";
echo strtotime ("+1 week"), "\n";
echo strtotime ("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime ("next Thursday"), "\n";
echo strtotime ("+ 3 months"), "\n";
echo("<br>");
echo("that was a break <br>");
echo((isset($_SERVER["REQUEST_TIME"]))?$_SERVER["REQUEST_TIME"]:"")
?>
<br>
<?php
$date = new DateTime('2000-01-20');
$date->sub(new DateInterval('P10D'));
echo $date->format('Y-m-d') . "\n";
?>
<br>
<?php
$date = new DateTime('2000-01-20');
$date->add(new DateInterval('P6M'));
echo $date->format('Y-m-d') . "\n";
?>
<br>
<?php
$date = new DateTime();
echo $date->format('Y-m-d') . "\n";
echo "no newline shown";
?>
None of the <br> or "<br>" code ws originally included.
The output from this is:
1332149953 1332664753 1332851955 1332374400 1340008753
that was a break
1332063553
2000-01-10
2000-07-20
2012-03-18 no newline shown
___________________
The "\n" code seems to do nothing.
If I replace it with "<br>" I get what I expected.
So what is the purpose of "\n" and when (if ever) can or should it be used.?
A newline character is consider whitespace and HTML treats whitespace as a single space character. You might want to use the newline character if you are creating a file or email.