Re: POLL: To add the final ?> or not...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2010-01-08 at 12:24 -0800, Daevid Vincent wrote:

> I'm having a debate with a co-worker about adding the final ?> on a PHP
> page...
> 
> To be honest, I am the lead, and I could pull rank and be done with the
> discussion, however I don't like to be that way. I would rather do the
> right thing. If my way of thinking is old-school (I've been coding since
> PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd
> rather adopt that, despite how icky it makes me feel to leave an unclosed
> <?php just dangling and alone, all sad-like. In my mind, "nobody gets left
> behind"! :)
> 
> Is there ANY side-effects to leaving the end ?> off? Is it any more work
> for the compiler? And yes I know computers are hella-fast and all that, but
> I come from the gaming industry where squeeking out an extra FPS matters,
> and shaving off 0.01s per row of data in a table matters if you have more
> than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso
> -- just try to talk for 10 seconds straight without a pause. Or sit there
> and stare at a screen for 10 seconds!
> 
> If the main argument is that it's to prevent white-space after the code,
> then most modern editors that I'm aware of will automatically trim
> white-space (or have a setting to do so). Plus this is ONLY a factor when
> you're trying to output a header and things like that. In 90% of your code,
> you don't deal with that. It's also obvious enough when you have an extra
> character/space because PHP pukes on the screen and TELLS you something
> about "blah blah sent before header output" or something to that effect.
> 
> What do you guys all do?
> 
> I also created a poll here http://www.rapidpoll.net/arc1opy
> 
> -----Original Message-----
> From: Co-worker
> To: Daevid Vincent
> 
> Actually, Zend states that you should omit the final ?> on include pages.
> There is no harm in the action, and it prevents you from accidentally
> adding white space after the tag which will break the code.  
> 
> http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm
> l
> 
> 
> -----Original Message-----
> From: Daevid Vincent 
> To: Co-worker
> 
> Please DO include the final ?> I noticed on several of your files that you
> have purposely omitted it. Yes, I know the files work without them, but it
> makes things easier to see the pairings for matching <?php . Plus it keeps
> things consistent and I'm not a big fan of "special cases" as this is,
> especially if it's a bad habit to get into since in all other cases it's
> required except this one "lazy" one. If you are concerned about white space
> sending in a header or something, well then just make sure there isn't any.
> I've had no problems and it makes you a more careful coder.
> 
> Thanks,
> 
> Daevid.
> 
> 


I always include the final ?> for neatness, and have had no problems
doing so. There is an argument that leaving off the ?> prevents
multibyte end of line markers from causing problems with headers being
sent when the PHP file is being included in another, but I've not had
this problem on the text editors I use.

That said, some systems do have coding style conventions regarding them,
so if your code is to be included in any of those, then maybe it's best
following their conventions.

Thanks,
Ash
http://www.ashleysheridan.co.uk



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux