PHP

ADD LINE BREAKS & NEW LINES IN PHP

$lines = "Line 1 Line 2 Line 3";

DEFINE LINE BREAKS AS-IT-IS

01

\r CARRIAGE RETURN \n NEW LINE

LINUX USES \n MAC USES \r WINDOWS USES \r\n

WE JUST USE \r\n REGARDLESS $lines = "Line1 \r\n Line 2";

LINE BREAK CHARACTERS

02

PHP_EOL IS AUTOMATICALLY \r, \n, OR \r\n BASED ON THE OS.

END-OF-LINE CONSTANT

03

$lines = "Line 1". PHP_EOL ."Line 2";

HTML BREAK - <BR> $lines = "Line 1<br>Line 2";

HTML LINE BREAKS

04