[PHP] What is white space
Most of the time, I edit files via the command line, (FBSD). When the files are saved, it adds a \n (newline) character (at least I believe that is what it is) after the closing ? When viewing these files in a windows GUI editor, there is an extra line after the ? closing tag. Using the php function headers_sent(), doesn't show that there is any output being created by these extra lines after closing ? So is white space only physical space (\s) or can it be anything like \t \r \n??? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is white space
--- Gerard Samuel [EMAIL PROTECTED] wrote: Most of the time, I edit files via the command line, (FBSD). When the files are saved, it adds a \n (newline) character (at least I believe that is what it is) after the closing ? When viewing these files in a windows GUI editor, there is an extra line after the ? closing tag. Using the php function headers_sent(), doesn't show that there is any output being created by these extra lines after closing ? So is white space only physical space (\s) or can it be anything like \t \r \n??? This is a feature/bug of PHP, depending on your perspective. When a closing ? is followed by a newline, the newline is not output. Hope that helps. Chris = Chris Shiflett - http://shiflett.org/ PHP Security Handbook Coming mid-2004 HTTP Developer's Handbook http://httphandbook.org/ RAMP Training Courses http://www.nyphp.org/ramp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is white space
On Sat, 2003-11-15 at 12:12, Chris Shiflett wrote: --- Gerard Samuel [EMAIL PROTECTED] wrote: Most of the time, I edit files via the command line, (FBSD). When the files are saved, it adds a \n (newline) character (at least I believe that is what it is) after the closing ? When viewing these files in a windows GUI editor, there is an extra line after the ? closing tag. Using the php function headers_sent(), doesn't show that there is any output being created by these extra lines after closing ? So is white space only physical space (\s) or can it be anything like \t \r \n??? This is a feature/bug of PHP, depending on your perspective. When a closing ? is followed by a newline, the newline is not output. FYI, if you're woprried about the header cannot be sent due to output... error, then if your file only has code and no HTML, then you can omit the ? tag at the end of your script. This solves countless issues with there being a space, a tab, a newline, or any whitespace after the closing tag. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is white space
Robert Cummings wrote: FYI, if you're woprried about the header cannot be sent due to output... error, then if your file only has code and no HTML, then you can omit the ? tag at the end of your script. This solves countless issues with there being a space, a tab, a newline, or any whitespace after the closing tag. And when that bug is fixed? -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is white space
It's not a bug. Anything (including spaces, newlines etc) that is not inside ? and ? is output directly to the browser. At 03:49 PM 11/15/2003, you wrote: Robert Cummings wrote: FYI, if you're woprried about the header cannot be sent due to output... error, then if your file only has code and no HTML, then you can omit the ? tag at the end of your script. This solves countless issues with there being a space, a tab, a newline, or any whitespace after the closing tag. And when that bug is fixed? -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is white space
On Sat, 2003-11-15 at 18:49, Leif K-Brooks wrote: Robert Cummings wrote: FYI, if you're woprried about the header cannot be sent due to output... error, then if your file only has code and no HTML, then you can omit the ? tag at the end of your script. This solves countless issues with there being a space, a tab, a newline, or any whitespace after the closing tag. And when that bug is fixed? Isn't that a feature? Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is white space
Yep. It allows you to only use php where needed, and use HTML for the rest. At 04:02 PM 11/15/2003, you wrote: On Sat, 2003-11-15 at 18:49, Leif K-Brooks wrote: Robert Cummings wrote: FYI, if you're woprried about the header cannot be sent due to output... error, then if your file only has code and no HTML, then you can omit the ? tag at the end of your script. This solves countless issues with there being a space, a tab, a newline, or any whitespace after the closing tag. And when that bug is fixed? Isn't that a feature? Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is white space
Keith Greene wrote: It's not a bug. Anything (including spaces, newlines etc) that is not inside ? and ? is output directly to the browser. No, I'm talking about not using ?. -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is white space
Keith Greene wrote: That's not a bug either. Leaving out the ? is simply telling the php parser that it has to parse the rest of the script. Where's the manual page saying that's allowed? -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is white space
Ok, you're getting into semantics now. http://www.php.net/manual/en/language.basic-syntax.php doesn't say whether it is acceptable or not, but as Robert pointed out, if your script is purely php, omitting it is a good way of eliminating the headache of trailing white spaces that may interfere with headers. Keith At 04:41 PM 11/15/2003, Leif K-Brooks wrote: Keith Greene wrote: That's not a bug either. Leaving out the ? is simply telling the php parser that it has to parse the rest of the script. Where's the manual page saying that's allowed? -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is white space
Keith Greene wrote: Ok, you're getting into semantics now. http://www.php.net/manual/en/language.basic-syntax.php doesn't say whether it is acceptable or not, but as Robert pointed out, if your script is purely php, omitting it is a good way of eliminating the headache of trailing white spaces that may interfere with headers. No, I'm getting into the reality that an undocumented feature may very well be a bug, and may disappear. -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is white space
--- Keith Greene [EMAIL PROTECTED] wrote: It's not a bug. Anything (including spaces, newlines etc) that is not inside ? and ? is output directly to the browser. There are two different things being discussed, and I'm not positive which is considered a bug. 1. When a closing PHP tag, such as ?, is followed by a newline, the newline is not output. 2. When a script has no closing PHP tag, such as ?, it is assumed to be the end of the file. Personally, I think the first makes no sense while the second makes perfect sense. The second, to me, is no different than how many other things are cleaned up automatically. Your database connections are closed even when you don't explicitly close them, for example. Should PHP throw an error when it reaches the end of the file and is still in PHP mode? Is that really a problem? Now, I admit that I am a big fan of symmetry, so I never omit a closing PHP tag. However, why should it be considered an error if the end of file is reached in PHP mode instead of output/HTML mode? The first point above annoys me to no end. Imagine this code: table tr td ? echo $username; ? /td /tr /table Now, I'm not trying to argue for one format over another, but doesn't it seem clear that the author of this code wanted the value of $username to be on its own row, indented by one tab within the opening and closing cell tags? Should the newline that follows the closing PHP tag not be output? I think that it should, but it is not. That's my argument. :-) Chris = Chris Shiflett - http://shiflett.org/ PHP Security Handbook Coming mid-2004 HTTP Developer's Handbook http://httphandbook.org/ RAMP Training Courses http://www.nyphp.org/ramp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is white space
On Saturday 15 November 2003 08:22 pm, Chris Shiflett wrote: 1. When a closing PHP tag, such as ?, is followed by a newline, the newline is not output. Im the original author to this thread, and this is an attempt to bring back this thread to square one, as it was straying in other directions that doesn't apply to me. Command Line editors used. ee, vi, vim, joe X GUI editors used Quanta, Gvim Currently all these editors add what appears to be a \n after a closing ? This I believe is normal, because all *nix files contain a \n at the end of lines. I had a theory that output buffering was cleaning up my code, but this isn't the case, as I've turned off output buffering and Im still getting the same results. Speaking of results. Im not getting the infamous headers sent error. My scripts operate normally. The reason why I started this topic was to get some ammunition to ward off windows GUI editor users who claim that my code contains white space after the closing ? tag. Some dummy code - x.php ?php ? y.php ?php include('./x.php'); var_dump(headers_sent()); ? y.php returns false, even though, there is apparently a \n after the closing ? tag of x.php You may download my dummy code and view them in a windows GUI php editor, and see the extra line after the closing ? http://www.trini0.org/white_space.zip So going back to my original question - So is white space only physical space (\s) or can it be anything like \t \r \n??? .Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php