NYCPHP Meetup

NYPHP.org

[nycphp-talk] testing a theory

Dan Cech dcech at phpwerx.net
Tue Feb 20 13:04:59 EST 2007


tedd wrote:
> At 8:22 PM -0500 2/19/07, Paul Houle wrote:
>>    Here's a fun fact about <?php that I figured out recently:  I
>> always used to write include files like
>>
>> <?php
>>
>> ...define some functions...
>> ...define some classes...
>> ...set a few global variables ...
>>
>> ?>[EOF]
>>
>>    where [EOF] is the end of the file.
>>
>>    The trouble was that from time to time,  people using certain
>> editors would cause spaces and carriage returns to appear after the
>> ?>.  This had the obnoxious effect of opening the output stream and
>> making it possible to send http headers,  set cookies and do other
>> important things.
>>
>>    One day I discovered that I didn't need the "?>"...  I could just
>> write
>>
>> <?php
>>
>> ... PHP code...
>> [EOF]
>>
>>    And it works just fine.  It scared the people at the office,  but
>> they were glad to be rid of a nagging problem.
> 
> That has always bothered me. I like symmetrical stuff. I start stuff, I
> finish stuff.
> 
> <start></start>
> {
> }
> ()
> 
> But, the idea that one purposely leaves something hanging, is
> 
> 
> tedd

Of course, and that is why I have standardized on a practice of ending
include files with the following:

// end of script

followed by a single linefeed (I use linux-style newlines in all php
files, and enforce the same in SVN.

Dan



More information about the talk mailing list