[PHP] PHP tags - any reasons to close ?
Hi, I have seen some projects where people start with opening tag ?php but they DON'T close it with ? This is especially the case of CONFIG.php files... 1) What's the reason of that? 2) What if you would not close any 100% PHP files? 3) What's the reason of making an empty space after ? I've also seen this in some projects. Thanks for ideas, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP tags - any reasons to close ?
On 23 Sep 2008, at 13:32, Martin Zvarík wrote: I have seen some projects where people start with opening tag ?php but they DON'T close it with ? This is especially the case of CONFIG.php files... 1) What's the reason of that? Closing the PHP tag is implicit at the end of a file to avoid extra unwanted white-space. 2) What if you would not close any 100% PHP files? Nobody would care. 3) What's the reason of making an empty space after ? I've also seen this in some projects. Pass, but without output buffering they may have problems with cookies and other header-setting features. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP tags - any reasons to close ?
I have seen some projects where people start with opening tag ?php but they DON'T close it with ? This is especially the case of CONFIG.php files... 1) What's the reason of that? One reason is if it's a library file for example, trailing white space would be considered as output, which typically you wouldn't want (eg you can't send headers after the output has started). If you don't use the closing PHP tag, you would avoid this. 2) What if you would not close any 100% PHP files? Nada. 3) What's the reason of making an empty space after ? I've also seen this in some projects. Don't know. Doesn't seem wise to me. -- Richard Heyes HTML5 Graphing for FF, Chrome, Opera and Safari: http://www.phpguru.org/RGraph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP tags - any reasons to close ?
Martin Zvarík schreef: Hi, I have seen some projects where people start with opening tag ?php but they DON'T close it with ? This is especially the case of CONFIG.php files... 1) What's the reason of that? 2) What if you would not close any 100% PHP files? I second what Robbert and Richard said, actually I'm pretty sure I've read Rasmus himself advocate the practice of leaving out the closing php tag on files that contain no output 3) What's the reason of making an empty space after ? I've also seen this in some projects. most likely someone with a borked editor or with a complete misunderstanding of output buffering, either way don't do it! Thanks for ideas, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP tags - any reasons to close ?
On Tue, Sep 23, 2008 at 8:32 AM, Martin Zvarík [EMAIL PROTECTED] wrote: Hi, I have seen some projects where people start with opening tag ?php but they DON'T close it with ? This is especially the case of CONFIG.php files... 1) What's the reason of that? 2) What if you would not close any 100% PHP files? 3) What's the reason of making an empty space after ? I've also seen this in some projects. Thanks for ideas, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If you can avoid closing the php block then do it. There are too many horrible editors and people who don't know what they're doing to even give yourself this headache. I can't count the number of times that my scripts have stopped working when I have output buffering turned off because someone else thought it'd be funny (not really) to put lots of extra line returns and spaces at the end of one of my files.
Re: [PHP] PHP tags - any reasons to close ?
Hi, First time I've seen code without closing tag is when I've read about Zend Framework and bellow is what they say about it. For files that contain only PHP code, the closing tag (?) is never permitted. It is not required by PHP, and omitting it prevents the accidental injection of trailing whitespace into the response. Regards, Michal Sokolowski 2008/9/23 Martin Zvarík [EMAIL PROTECTED] Hi, I have seen some projects where people start with opening tag ?php but they DON'T close it with ? This is especially the case of CONFIG.php files... 1) What's the reason of that? 2) What if you would not close any 100% PHP files? 3) What's the reason of making an empty space after ? I've also seen this in some projects. Thanks for ideas, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP tags - any reasons to close ?
On Sep 23, 2008, at 9:27 AM, Jochem Maas wrote: Martin Zvarík schreef: Hi, I have seen some projects where people start with opening tag ?php but they DON'T close it with ? This is especially the case of CONFIG.php files... 1) What's the reason of that? 2) What if you would not close any 100% PHP files? I second what Robbert and Richard said, actually I'm pretty sure I've read Rasmus himself advocate the practice of leaving out the closing php tag on files that contain no output Before I go and change all of my include files... I just want to make sure if output would be considered inside a function that sets session variables, and then simply returns at the end? Once I'm done debugging, I'll have some functions like that hopefully. :) -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP tags - any reasons to close ?
-Original Message- From: Martin Zvarík [mailto:[EMAIL PROTECTED] 3) What's the reason of making an empty space after ? I've also seen this in some projects. I often put a number of empty lines at the end of a script since I enjoy editing with the script higher up on the screen, and very few editors allow you to scroll the last lines of the program above the bottom of the screen. (Crimson Editor is the only one I have found that does this.) Thanks for ideas, Martin Simcha Younger -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP tags - any reasons to close ?
At 2:32 PM +0200 9/23/08, Martin Zvarík wrote: Hi, I have seen some projects where people start with opening tag ?php but they DON'T close it with ? This is especially the case of CONFIG.php files... 1) What's the reason of that? 2) What if you would not close any 100% PHP files? 3) What's the reason of making an empty space after ? I've also seen this in some projects. Thanks for ideas, Martin Martin: I've heard all the reasons why one should not put a ? at the end of a php file, but for me, I'm just a creature of habit -- I like symmetrical things. Certainly I know the minor dangers of white space, but I always make certain that my files end with ? with no trailing white space. Like with all programming languages, if you do it right, it will work right*. Cheers, tedd * (unless you're working with IE) :-) -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP tags - any reasons to close ?
Jason Pruim schreef: On Sep 23, 2008, at 9:27 AM, Jochem Maas wrote: Martin Zvarík schreef: Hi, I have seen some projects where people start with opening tag ?php but they DON'T close it with ? This is especially the case of CONFIG.php files... 1) What's the reason of that? 2) What if you would not close any 100% PHP files? I second what Robbert and Richard said, actually I'm pretty sure I've read Rasmus himself advocate the practice of leaving out the closing php tag on files that contain no output Before I go and change all of my include files... I just want to make sure if output would be considered inside a function that sets session variables, and then simply returns at the end? Once I'm done debugging, I'll have some functions like that hopefully. :) by 'output' I meant any 'plain text' hanging around outside of php tags, e.g.: foo.php - ?php function myFunc() { return Hello World; } echo myFunc(); // the rest (after '?') I'm calling 'output' ? some static outputbr / isn't it great!hr / - more specifically 'output' after the last block of php in a file. basically EOF implies '?' (if your in a php block) so why type '?' and take the risk of having some trialing white space screw up your app. sorry for the confusion my output may have caused ;-) -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP tags - any reasons to close ?
On Tue, 2008-09-23 at 14:37 +0100, Michal Sokolowski wrote: Hi, First time I've seen code without closing tag is when I've read about Zend Framework and bellow is what they say about it. For files that contain only PHP code, the closing tag (?) is never permitted. It is not required by PHP, and omitting it prevents the accidental injection of trailing whitespace into the response. Support for omitting the closing PHP tag is a feature. Search the archives if you need verification. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP tags - any reasons to close ?
On Tue, Sep 23, 2008 at 12:28 PM, Robert Cummings [EMAIL PROTECTED] wrote: On Tue, 2008-09-23 at 14:37 +0100, Michal Sokolowski wrote: Hi, First time I've seen code without closing tag is when I've read about Zend Framework and bellow is what they say about it. For files that contain only PHP code, the closing tag (?) is never permitted. It is not required by PHP, and omitting it prevents the accidental injection of trailing whitespace into the response. Support for omitting the closing PHP tag is a feature. Search the archives if you need verification. Cheers, Rob. Correct. The line Michal quoted is describing a coding standard in the Zend Framework, not a language requirement. Obviously closing tags are always permitted in PHP. The Zend Framework team has just adopted a standard that they are not to be used within the framework codebase itself, for the reasons stated in the rest of the quoted reference. Thus, within their standard, the closing tag is never permitted. :-) Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP tags - any reasons to close ?
Simcha Younger wrote: I often put a number of empty lines at the end of a script since I enjoy editing with the script higher up on the screen, and very few editors allow you to scroll the last lines of the program above the bottom of the screen. (Crimson Editor is the only one I have found that does this.) vi has no problem doing that. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP tags - any reasons to close ?
On Tue, 23 Sep 2008 19:48:12 +0200, Per Jessen wrote: Simcha Younger wrote: I often put a number of empty lines at the end of a script since I enjoy editing with the script higher up on the screen, and very few editors allow you to scroll the last lines of the program above the bottom of the screen. (Crimson Editor is the only one I have found that does this.) vi has no problem doing that. Geany does this too, unless you ask it not to (preferences). -- Ross McKay, Toronto, NSW Australia Let the laddie play wi the knife - he'll learn - The Wee Book of Calvin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php