Dimitri Vorontzov Posted December 10, 2012 Share Posted December 10, 2012 My question is mainly regarding Chapter 11, sub-chapter "Understanding HTTP Headers", Pg. 357 - but it also includes more general basic question. There's a line on Pg. 357: "Before getting to the example, note that if a script uses multiple header( ) calls, each should be terminated by a newline (\n) as in the preceding code snippets." Why? (The reason isn't explained in the book.) Also. I see that Larry is using \n quite liberally in his code. I want to understand the reasons. One of them, probably the main one, I guess, is to make the resulting HTML code more readable. What are other possible reasons? Link to comment Share on other sites More sharing options...
Antonio Conte Posted December 11, 2012 Share Posted December 11, 2012 Weird. I cannot see anything in the manual that explains that. Non of the comments include header calls that uses newline ending either. I'm sure he explains it in the book if there's some special reason for this. (Maybe you just missed it?) Yes. Newlines are applied because of legibility. It serves no other purpose functionally. Another reason could, however, be because a file is supposed to be read with PHP or another language. You need some way to tell this reader where a line ends, or it will read everything as a single line. Text editors applies these to the text without telling us, but they must exist. Please notice that line endings may depend of OS, so it's not save to only look for "\n"s. ini_set('auto_detect_line_endings', true); The line above will normalize the line endings for you. 1 Link to comment Share on other sites More sharing options...
Larry Posted December 12, 2012 Share Posted December 12, 2012 Hmmm...good question. Years ago I'm pretty sure I read you had to do that to separate multiple header calls but I don't see that anywhere in the documentation either. 2 Link to comment Share on other sites More sharing options...
Dimitri Vorontzov Posted December 13, 2012 Author Share Posted December 13, 2012 So, should this be considered as erroneous information in the book, and go to Errata? Link to comment Share on other sites More sharing options...
Larry Posted December 14, 2012 Share Posted December 14, 2012 I don't see the need for this to be on the errata page. It's not something that's wrong or prevents someone from actually getting it to work. Link to comment Share on other sites More sharing options...
Recommended Posts