Back in my day, if you had more than one blank line after a closing PHP and tried to start a session, you would get an error stating the headers were already sent. This was because the parser would strip out one blank line only. by forcing it in a standard, it would help prevent such silly mistakes when some one is using your lib.
On Tuesday, January 24, 2017 at 10:36:13 AM UTC-5, Jason Judge wrote: > > > > On Tuesday, 24 January 2017 03:25:36 UTC, Ahmad Samiei wrote: >> >> ... >> >> Re: Ex. Why a blank line at the end of PHP documents? >> Definition of a line in POSIX standard >> <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206> >> : >> 3.206 Line: A sequence of zero or more non- <newline> characters plus a >> terminating <newline> character >> >> Otherwise, some programs might have problems processing the last line >> then. >> Many editors and tools (ex. git) show a warning message if there is no >> newline at the end of file. >> >> > Based on this definition, a blank line has zero non-<newline> characters > before its terminating <newline>. So that means a PHP file must end with > TWO sequential <newline> characters in order to end the file with a blank > line. > > However - that was never the intention of that PSR statement. There is NO > need to put a blank line on the end of each PHP script, in fact you MUST > NOT have a blank line. You just need to make sure the file consists of > *lines* according to the POSIX standard, and that the last line is NOT > blank. It's misleading, and hopefully the replacement for this > recommendation will make it clearer. > > The confusion came from what people *think* they are looking at when > viewing a script in their favourite editor, rather than how the file is > really constructed. > > -- Jason > -- You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/63eddfa4-d75f-4db6-9752-049309d2b680%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
