[ 
https://issues.apache.org/jira/browse/THRIFT-718?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12839663#action_12839663
 ] 

Nicholas Telford commented on THRIFT-718:
-----------------------------------------

Didn't realise I'd mixed the line-endings, I'll try to fix those in the patch.

Closing tags on their own are fine, but can potentially cause problems because 
*any* characters afterwards will cause output to be sent to the browser (unless 
output buffering is enabled) before headers are sent - cue PHP WARNING.

In the case of the Thrift interface, it seems you've intentially added 
characters (yes, by whitespace I meant the LFs) after the closing tags. This 
illustrates why closing tags are dangerous.

Omitting the closing tags allows you to add as much whitespace to the end of 
the file as you like, because PHP will never output them.

This is an official part of the Zend Framework coding standards, and I believe 
other frameworks and libraries have also adopted the practice. More details 
here: 
http://framework.zend.com/manual/en/coding-standard.php-file-formatting.html

PEAR is a bit of a mess, I wouldn't trust it implicitly.

> Thrift PHP library includes closing tags and extraneous whitespace
> ------------------------------------------------------------------
>
>                 Key: THRIFT-718
>                 URL: https://issues.apache.org/jira/browse/THRIFT-718
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Library (PHP)
>            Reporter: Nicholas Telford
>         Attachments: thrift_php_closingTags.diff
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Extraneous whitespace after a PHP script's closing tag (?>) can cause big 
> problems when sending headers to the client.
> It is generally advised that closing PHP tags be omitted from the end of a 
> PHP file to prevent extraneous whitespace being an issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to