Echo on new line php
A simple one!
In PHP, you can use the echo
statement followed by a newline character (\n
) to print output on a new line. Here are a few ways to do it:
-
Using
\n
:echo "Hello, world!\n";
This will print "Hello, world!" followed by a newline character.
-
Using
PHP_EOL
:echo "Hello, world!". PHP_EOL;
PHP_EOL
is a constant that represents the end-of-line character for the current platform (e.g.,\n
on Unix,\r\n
on Windows). -
Using
echo
with a newline character in a string:echo "Hello, world!\r\n";
This will also print "Hello, world!" followed by a newline character.
Note that the \r
character is not necessary on Unix-based systems, but it's included here for completeness.
All of these examples will print the output on a new line.