On 3 Apr 2012, at 22:29, Tedd Sperling wrote:
> Let me start a religious war -- should one end their scripts with "?>" or not?
>
> After years of never having a problem with ending any of my scripts with
> "?>", I found that several students in my class had scripts that did not
> produce the desired result even after they were given the scripts via
> highlight_file(") to cut and paste.
>
> As it turned out, several students copy/pasted the script with an addition
> whitespace after the ending "?>" and as such the scripts did not run as
> expected. You see, the scripts created image but apparently the image
> delivery method objected to the additional whitespace.
>
> Does anyone have more examples of where scripts will fail IF they end with
> "?> " (note the additional space)?
Usually when setting headers after such a script has been included when output
buffering is turned off. Personally I never put the closing ?> in if it's at
the end of the file because it's unnecessary and can cause issues if it's
present, but it's personal preference more than anything else.
Ultimately you have to consider that there's a reason it's optional - things
like that don't generally happen by accident. I remember Rasmus commenting on
this style issue a few years back so a search of the archives should find an
"official" position.
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php