xxxxxxxxxx
<?php
echo "Hello world this is example \r\n in php.";
echo "<br>";
echo nl2br("You will find the \n newlines in this string \r\n on the browser window.");
?>
Make sure its double quotes '' '' or else line breaks (\n) won't work with single quotes ' '
xxxxxxxxxx
echo "\n";
xxxxxxxxxx
<?php
echo "Hello, World!".PHP_EOL;
echo "Hello, World! \n";
echo "Hello, World! \r\n";
echo "Hello, World! \n";
echo nl2br("Hello World! \r\n 123456 <br> abcdefg");
?>
xxxxxxxxxx
<?php
echo nl2br("If you want that '\n' works. \n Then use nl2br() function!");
echo "<br> can also be used.";
echo "nl2br() is in-built function whereas <br> is html tag";
?>