Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
How to output on a newline in php
4 Respostas
+ 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.";