+ 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"; } ?>
3 Answers
+ 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 ;)
+ 2
In browser to see line break you must use <br> tag
0
Thanks for the advice!