hi i’m learning php from the beginners guide and it has
a lot of times is this still valid as it has no effect for me? or am i missing the point.
Thanks for any explanation.
If you view your page source you will see what effect it has; try writing something simple like a table once with
and once without.
e.g.
<?php
echo "<table>\
<tr>\
<td>Cell 1</td>\
<td>Cell 2</td>\
</tr></table>";
echo "<table><tr><td>Cell 3</td><td>Cell 4</td></tr></table>";
?>
Which is easier to error check ?
Rubble, I was creating pages with html5 doctype and thought that was it, tried with transitional and still the same nothing is no different I thought the data was supposed to go to the next line? it doesn’t.
I am on wamp is this the reason?
Thanks
Pop this in a script, by itself…
<?php
foreach(range(1, 5) as $i){
echo $i, '<br />', "\
" ;
}
You should get…
/*
1<br />
2<br />
3<br />
4<br />
5<br />
*/
Anthony, all i get is
1,2,3,4,5 vertically with no br tags.
do you think its some of my settings in my ini file?
Try this then…
<?php
echo 'PHP says the new line char is ' . ord(PHP_EOL) . PHP_EOL ;
foreach(range(1, 5) as $i){
echo $i, '<br />', PHP_EOL ;
}
Don’t look at what the browser outputs, look at the HTML sourcecode produced (Ctrl+U on most browsers, ALT+V+C on IE).
The
simply adds a line to the source. It has little effect on the browser’s output. Its main uses are for debugging purposes, however it has significant use in file writing.
Anthony, It said the php says the new line char is 13 1 then on a new line everytime it printed out 2,3,4,5
should i try xammp ? or a server on the web?
jake,
Your correct !! and anthony your are also correct it just doesnt display properly in my browser. should i look at the code in the ctrl u after i have executed the program.?
im on FF as that is the browser that is set up with wamp.
Thank guys