Page 1 of 2

Trailing line at end of files

Posted: Thu Jun 21, 2007 7:40 pm
by Ambush Commander
I'm curious. It seems like most Unix tools expect there to be a trailing newline at the end of files; I've always been careful to make sure ?> is the last data in a file so that I don't get the dreaded headers already sent warning.

Posted: Thu Jun 21, 2007 7:45 pm
by feyd
A trailing new-line after the ?> is fine, provided no other characters are between them.

Posted: Thu Jun 21, 2007 7:46 pm
by Ambush Commander
I was vaguely aware that is the case. Of course, if you have two lines...

Posted: Thu Jun 21, 2007 8:07 pm
by superdezign
Ambush Commander wrote:I was vaguely aware that is the case. Of course, if you have two lines...
That extra newline would be something between the ?> and the allowed newline. :P

Posted: Thu Jun 21, 2007 8:09 pm
by Christopher
I don't use ?> which seems to be the Zend approved thing to do.

Posted: Thu Jun 21, 2007 8:11 pm
by Ambush Commander
::does a quick test::

I never realized that; how long has this been allowed?

Posted: Thu Jun 21, 2007 8:16 pm
by Christopher
I get the sense that is has always been the case. When the EOF is reached, PHP ends parsing whether in HTML or PHP mode. In class files, using no ?> is the Zend recommendation.

Posted: Thu Jun 21, 2007 8:22 pm
by superdezign
arborint wrote:I get the sense that is has always been the case. When the EOF is reached, PHP ends parsing whether in HTML or PHP mode. In class files, using no ?> is the Zend recommendation.
In Dreamweaver, leaving it out causes the whole file to be highlighted in yellow. I've no idea how to disable that. :x

Posted: Thu Jun 21, 2007 8:24 pm
by feyd
superdezign wrote:In Dreamweaver, leaving it out causes the whole file to be highlighted in yellow. I've no idea how to disable that. :x
Stop using Dreamweaver. :twisted:

Posted: Thu Jun 21, 2007 9:14 pm
by superdezign
That would seem like such a waste of money... :(

Posted: Thu Jun 21, 2007 9:24 pm
by feyd
superdezign wrote:That would seem like such a waste of money... :(
It was. :)

Posted: Thu Jun 21, 2007 10:00 pm
by superdezign
:lol:

Which do you suggest? I used to use one called PHP Editor, but didn't like it. Is there anything similar to Visual Studio? (where it shows you your class structures and such)

Posted: Thu Jun 21, 2007 10:06 pm
by feyd
superdezign wrote:Which do you suggest? I used to use one called PHP Editor, but didn't like it. Is there anything similar to Visual Studio? (where it shows you your class structures and such)
We're pushing pretty far out of subject with this line of discussion, so might I suggest you read through the novel that is our "editors" thread? :)

Posted: Thu Jun 21, 2007 10:06 pm
by Benjamin
On Topic: I never use ?> so I don't have to worry about whether or not there is anything after it.

Off Topic: Use Eclipse. Better yet, Use Eclipse in Linux. Quanta is great too. I'd do either.

Posted: Thu Jun 21, 2007 11:26 pm
by John Cartwright
Zend IDE automatically removes trailing newlines.

$Zend++