Re: [PHP] To ?> or not to ?>
Larry Garfield wrote: [snip] Donovan Most major projects at this point leave it off, and their coding standards say to as well. The official PHP docs are generally non-commital by design, but outside of those I think it's pretty well-established to just leave it off and be happy. --Larry Garfield Well, the preference doesn't really matter to me... my point of question was the use of ob_start, etc.. The books I've read in PHP also call for ending '?>', so it's being taught to PHP'ers whether the php list and major projects likes it or not. I was wondering about the lists opinion on the use of ob_start, ob_end_flush regarding this topic. Donovan -- D Brooke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] To ?> or not to ?>
On 4/4/12 12:14 AM, Donovan Brooke wrote: Robert Cummings wrote: [snip] Could using ob_start and ob_end_flush eliminate the ambiguity of whether or not to use '?>'? In the generally recommended case of don't use them at the end of your file... where's the ambiguity? http://www.php.net/manual/en/function.include.php http://www.php.net/manual/en/language.basic-syntax.phpmode.php Those seem to suggest to use them... thus the ambiguity. Donovan Most major projects at this point leave it off, and their coding standards say to as well. The official PHP docs are generally non-commital by design, but outside of those I think it's pretty well-established to just leave it off and be happy. --Larry Garfield -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] To ?> or not to ?>
Robert Cummings wrote: I'm not alone then :) But I prefer EVERY tag to be closed ... perhaps that would change if the IDE's faked a closing tag when it's missing so they don't get flagged as an error :( IDE? Get off my lawn!! ;) I develop in JOE. But that does not provide any of the VCS/DVCS interlinks ... and flag files which have errors in them based on file extension ;) My niggle here is cloning local copies of libraries which get flagged with errors in files which one then has to check as to the reasons :( But if no one else is going to fix things then it's probably time to get my Java books out again and do it myself ... -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] To ?> or not to ?>
On 12-04-04 04:40 PM, Lester Caine wrote: ( forget email addres :( ) Robert Cummings wrote: On 12-04-04 02:42 PM, Lester Caine wrote: Tedd Sperling wrote: Let me start a religious war -- should one end their scripts with "?>" or not? Just as long as no one proposes making leaving out compulsory ;) While I can sort of understand the logic when the file is all php and just has an opening These kinds of files don't generally have issues with trailing whitespace though :) I certainly close the tags in these cases. I'm not alone then :) But I prefer EVERY tag to be closed ... perhaps that would change if the IDE's faked a closing tag when it's missing so they don't get flagged as an error :( IDE? Get off my lawn!! ;) I develop in JOE. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] To ?> or not to ?>
( forget email addres :( ) Robert Cummings wrote: On 12-04-04 02:42 PM, Lester Caine wrote: Tedd Sperling wrote: Let me start a religious war -- should one end their scripts with "?>" or not? Just as long as no one proposes making leaving out compulsory ;) While I can sort of understand the logic when the file is all php and just has an opening These kinds of files don't generally have issues with trailing whitespace though :) I certainly close the tags in these cases. I'm not alone then :) But I prefer EVERY tag to be closed ... perhaps that would change if the IDE's faked a closing tag when it's missing so they don't get flagged as an error :( -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] To ?> or not to ?>
On 12-04-04 02:42 PM, Lester Caine wrote: Tedd Sperling wrote: Let me start a religious war -- should one end their scripts with "?>" or not? Just as long as no one proposes making leaving out compulsory ;) While I can sort of understand the logic when the file is all php and just has an opening These kinds of files don't generally have issues with trailing whitespace though :) I certainly close the tags in these cases. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] To ?> or not to ?>
Tedd Sperling wrote: Let me start a religious war -- should one end their scripts with "?>" or not? Just as long as no one proposes making leaving out compulsory ;) While I can sort of understand the logic when the file is all php and just has an opening closing tags AND using totally wrong? -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] To ?> or not to ?>
On 12-04-04 01:14 AM, Donovan Brooke wrote: Robert Cummings wrote: [snip] Could using ob_start and ob_end_flush eliminate the ambiguity of whether or not to use '?>'? In the generally recommended case of don't use them at the end of your file... where's the ambiguity? http://www.php.net/manual/en/function.include.php http://www.php.net/manual/en/language.basic-syntax.phpmode.php Those seem to suggest to use them... thus the ambiguity. From an age long gone when I asked the exact same question and Big Daddy answered: http://marc.info/?l=php-internals&m=106896382030183&w=2 Then again a couple of years later: http://marc.info/?l=php-internals&m=112537775409619&w=2 And in the manual itself (see the note): http://ca.php.net/basic-syntax.instruction-separation Zend Framework and Drupal are examples of large codebases that have adopted the omission as a best practice. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] To ?> or not to ?>
I keep my closing tag. Earlier I started removing closing tag. Then I search for the standardness of this practice and found its not standard. Some frameworks/cms intentionally do this. Besides a signle `\n` character is allowed after the closing tag which does not cause "Can not send Header" error. So I started using closing tag again. Later I found, from visual aspect, a closing tag makes the code balanced. Still using it. -- Shiplu.Mokadd.im ImgSign.com | A dynamic signature machine Innovation distinguishes between follower and leader
Re: [PHP] To ?> or not to ?>
Robert Cummings wrote: [snip] Could using ob_start and ob_end_flush eliminate the ambiguity of whether or not to use '?>'? In the generally recommended case of don't use them at the end of your file... where's the ambiguity? http://www.php.net/manual/en/function.include.php http://www.php.net/manual/en/language.basic-syntax.phpmode.php Those seem to suggest to use them... thus the ambiguity. Donovan -- D Brooke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] To ?> or not to ?>
On 12-04-03 11:39 PM, Donovan Brooke wrote: Stuart Dallas wrote: [snip] 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 Could using ob_start and ob_end_flush eliminate the ambiguity of whether or not to use '?>'? In the generally recommended case of don't use them at the end of your file... where's the ambiguity? Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] To ?> or not to ?>
Stuart Dallas wrote: [snip] 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 Could using ob_start and ob_end_flush eliminate the ambiguity of whether or not to use '?>'? Donovan -- D Brooke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] To ?> or not to ?>
I leave them off of any non-view PHP file. It doesn't have any downsides, and leaving them in can cause problems. Just like short tags! Regards, –Josh Joshua Kehn | @joshkehn http://joshuakehn.com On Apr 3, 2012, at 5:29 PM, Tedd Sperling wrote: > Hi gang: > > 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)? > > Cheers, > > tedd > > _ > tedd.sperl...@gmail.com > http://sperling.com > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >
Re: [PHP] To ?> or not to ?>
On 12-04-03 05:29 PM, Tedd Sperling wrote: Hi gang: 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)? It's standard practice to NOT include the closing ?> on anything remotely resembling a class or lib source file. As has been mentioned on this list and originally on PHP internals on several occasions, the optionality of the closing tag is intentional :) Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] To ?> or not to ?>
On Apr 3, 2012, at 2:29 PM, Tedd Sperling wrote: > Hi gang: > > 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)? > > Cheers, > > tedd I believe this can also be problematic if script A ends with "?> " (with additional space) and script B includes script A at the top, which will cause the headers to be sent. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] To ?> or not to ?>
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
[PHP] To ?> or not to ?>
Hi gang: 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)? Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php