I was trying to add a line break for a sentence, and I added /n in following code.
echo "Thanks for your email. /n Your orders details are below:".PHP_EOL;
echo 'Thanks for your email. /n Your orders details are below:'.PHP_EOL;
For some reasons, the I got server error as the result. How do I fix it?
\nis a line break./nis not.use of
\nwith1. echo directly to page
Now if you are trying to echo string to the page:
output will be:
you won’t get
gardenin new line because PHP is a server-side language, and you are sending output as HTML, you need to create line breaks in HTML. HTML doesn’t understand\n. You need to use thenl2br()function for that.What it does is:
Output
2. write to text file
Now if you echo to text file you can use just
\nand it will echo to a new line, like:output will be: