0
How to output on a newline in php
4 Answers
+ 5
Use the newline Characters ' \n ' or ' \r\n ' You can use the PHP newline characters \n or \r\n to create a new line inside the source code. However, if you want the line breaks to be visible in the browser too, you can use the PHP nl2br() function which inserts HTML line breaks before all newlines in a string.
+ 1
You can't use \n to issue a line break by echo. When you do echo here the output is written into a web page body, thus you need to use HTML line break.
echo "My name is Patrick.<br />";
echo "I'm learning PHP on SoloLearn.";
P.S. Can you please edit the tags? It is not recommended to write your question into the tags. But you can keep PHP in there, it is a relevant language in regards to the question đ
0
Alright. Let me try that. Thanks.
0
Hi
I used the '\n' in Sololearn code playground but it seems not to work.
This is exactly what I wrote:
echo "My name is Patrick. '\n' ";
echo "I'm learning PHP on Sololearn.";