ddefebbo Posted August 21, 2015 Share Posted August 21, 2015 On page 23, there is a section in grey on using white space. The example shown is this: print "Line 1\nLine2"; I tested this and it returns simply Line 1 Line 2 I looked in the PHP manual and found that I can use \n in the nl2br function. I tried it using this code: print nl2br("Line 1\nLine 2"); And that worked, outputting this: Line 1 Line 2 Is this an error in the book, or am I missing something. I checked the errata and found nothing. Clearly I found one way (maybe the only way?), but I am wondering if I am missing something about how it is explained in chapter 1? Link to comment Share on other sites More sharing options...
Larry Posted August 22, 2015 Share Posted August 22, 2015 Sorry for the confusion about this! If you reread that sidebar on page 23, after that code, you'll see it says "Again, use of the newline character affects the HTML source code of the Web page, not what the end user will see rendered in the browser." If you use that code (not nl2br()) and then check the HTML source code of the resulting page, you'll see the effect. Link to comment Share on other sites More sharing options...
ddefebbo Posted August 24, 2015 Author Share Posted August 24, 2015 Ohh! Thanks for the clarification. So it is used for ease of viewing the source code, rather than the public rendering. Makes sense. Link to comment Share on other sites More sharing options...
Recommended Posts