+ 1

A bug in the PHP interpreter

The special character "\n" does not work!!! Check: <?php for($x=0;$x<=10;$x++){ echo "$x\n"; } ?>

7th Jan 2017, 7:38 AM
Пешков Павел
Пешков Павел - avatar
3 Respostas
+ 4
@Suleyman says: "In browser to see line break you must use <br> tag" Or encapsulate your output in a <pre></pre> tag ( PREformatted text ), which keep the lines breaking with \n: <?php echo "<pre>"; for($x=0;$x<=10;$x++){ echo "$x\n"; } echo "</pre>"; ?> @Suleyman solution is shorter: <?php for($x=0;$x<=10;$x++){ echo "$x<br>"; } ?> ... but <pre> is usefull when having already a text output without the html line-break tag ( ie: like the "to string' output if an array ) ^^ Any html tag can be css styling to reproduce ( or cancel ) the behaviour of the pre tag, with the white-space property ( possibles values: normal, nowrap, pre, pre-wrap, pre-line... -- see https://developer.mozilla.org/en-US/docs/Web/CSS/white-space for more informations ;)
7th Jan 2017, 10:05 AM
visph
visph - avatar
+ 2
In browser to see line break you must use <br> tag
7th Jan 2017, 9:00 AM
Suleiman
0
Thanks for the advice!
19th Mar 2017, 9:22 AM
Пешков Павел
Пешков Павел - avatar