Trailing line at end of files

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Do you have trailing newlines on your files?

Yes
2
29%
No
5
71%
 
Total votes: 7

User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

I do have newlines. A long while back I stopped using the closing tags though so it's a non-issue for me.
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

Post by djot »

-
The phpeclicpse (plugin for eclipse) framework unfortunately has the trailing line in the default php template. I always remove all empty lines in top or at the bottom of all files (not only in PHP files). I sometimes had problems with "headers already sent" when there were empty lines after the closing PHP tag.

djot
-
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

In all of my PHP history, I've never had even one headers sent error due to trailing newlines
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

As people has previously mentioned, leaving out closing tag is good for your php

About newlines... I don't know and I don't care since it doesn't cause any trouble either way.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

The Ninja Space Goat wrote:In all of my PHP history, I've never had even one headers sent error due to trailing newlines
Happened to me once, but PHP told me which file and it was as simple as hitting backspace to fix. I always close the tags.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I don't use the ?> tag, but I always ensure I have a traiing newline after the closing } brace of my class.

It just looks wrong to me when a file ends without a blank line. Some UNIX tools will warn you about missing newlines too. It's probably something to do with each line expected to have EOL after it.

Emacs will warn you if you try to save a file without a trailing line from what I remember. nano/pico add a newline automatically.
Post Reply