RE: [PHP] POLL: To add the final ? or not...
I think someone has been having fun with the Poll... ;-) It used to be like 10::20 and now it's 71::31... Hmmm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
Hey Haven't had the time to read up on the maillist, but here's my input. Mattias Thorslund wrote on 09/01/2010 02:26: To my eyes, ? means look there is more content coming, which seems kind of silly when there isn't. To mine it means, no more PHP code for now. I don't wanna make it diffenrent from a file containing pure PHP code or one that contains both PHP and HTML, where I jump in and out of the PHP tag. Remember the ? stops the parser And I find it bad coding standard to start a tag and not end it, even if it's possible. Remember Perl is a smart, but also terrible language, where one can leave out the ; in the end of a oneline script and make a bunch of stuff on $_ without showing what variable you're working on. And finally, mysql_close() was always called after a script was closed, so I've never learned to practice that and for the last ten years I've seen only _one_ developer added that function call to the end of his files. In PHP6 that call is required, so making the cleanest code is in my opinion more readable and also more correct, since you'll never know what the PHP core team will come up with next ;-) A neat thing with pairing every ?php with a ? when mixed in HTML is that these are valid XML processing instructions. If your HTML satisfies XML well-formedness, your PHP document will also be valid XML. Not that I've ever had any need to process my layout templates as XML but anyway. I don't see your argument. PHP generates HTML or XML files. When you're aware of the XML tag of course you make sure the XML file generated is valid. Why would you ever add PHP code to a HTML file (other than for documentation, examples etc.)? -- Kind regards Kim Emax - masterminds.dk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
John Corry wrote on 12/01/2010 17:04: I leave ? out. I'm pretty careful about my code formatting and whitespace. It's my opinion that if I can eliminate a potential problem by not including an optional closing tag...there's really no reason why I shouldn't. What is the difference between: ? print hello PHPeople; ?WHITESPACE and ? print hello PHPeople; WHITESPACE Same shit when I look at it, a sloppy developer is what it is :-) -- Kind regards Kim Emax - masterminds.dk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
On Thu, 2010-01-14 at 23:30 +0100, Kim Madsen wrote: John Corry wrote on 12/01/2010 17:04: I leave ? out. I'm pretty careful about my code formatting and whitespace. It's my opinion that if I can eliminate a potential problem by not including an optional closing tag...there's really no reason why I shouldn't. What is the difference between: ? print hello PHPeople; ?WHITESPACE and ? print hello PHPeople; WHITESPACE Same shit when I look at it, a sloppy developer is what it is :-) -- Kind regards Kim Emax - masterminds.dk Plenty of differences, if you include the first one as a file, the whitespace gets sent to the browser because it is not part of the PHP, and so is assumed to be HTML. Once this happens, the headers have been sent, so you can't use different headers in your script. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] POLL: To add the final ? or not...
Ashley Sheridan wrote on 14/01/2010 23:30: What is the difference between: ? print hello PHPeople; ?WHITESPACE and ? print hello PHPeople; WHITESPACE Same shit when I look at it, a sloppy developer is what it is :-) -- Kind regards Kim Emax - masterminds.dk Plenty of differences, if you include the first one as a file, the whitespace gets sent to the browser because it is not part of the PHP, and so is assumed to be HTML. Once this happens, the headers have been sent, so you can't use different headers in your script. Hmm... you could be right. I guess I just never made that mistake :-) -- Kind regards Kim Emax - masterminds.dk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
On Thu, 2010-01-14 at 23:37 +0100, Kim Madsen wrote: Ashley Sheridan wrote on 14/01/2010 23:30: What is the difference between: ? print hello PHPeople; ?WHITESPACE and ? print hello PHPeople; WHITESPACE Same shit when I look at it, a sloppy developer is what it is :-) -- Kind regards Kim Emax - masterminds.dk Plenty of differences, if you include the first one as a file, the whitespace gets sent to the browser because it is not part of the PHP, and so is assumed to be HTML. Once this happens, the headers have been sent, so you can't use different headers in your script. Hmm... you could be right. I guess I just never made that mistake :-) -- Kind regards Kim Emax - masterminds.dk What has been said on this thread a few times is it is not always a developer error, but a bug with the editor, which is not something that will be picked up until it occurs. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] POLL: To add the final ? or not...
Ashley Sheridan wrote on 14/01/2010 23:36: What has been said on this thread a few times is it is not always a developer error, but a bug with the editor, which is not something that will be picked up until it occurs. Once again I love my VIm :-) (with whitespace highlight if needed) -- Kind regards Kim Emax - masterminds.dk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
On Fri, 2010-01-15 at 00:04 +0100, Kim Madsen wrote: Ashley Sheridan wrote on 14/01/2010 23:36: What has been said on this thread a few times is it is not always a developer error, but a bug with the editor, which is not something that will be picked up until it occurs. Once again I love my VIm :-) (with whitespace highlight if needed) -- Kind regards Kim Emax - masterminds.dk I'm a fan of Kate myself, can recognise pretty much any language you throw at it, and has a couple of neat plugins for web development Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] POLL: To add the final ? or not...
Wait, Kim, whats your last name? On Thu, Jan 14, 2010 at 5:04 PM, Kim Madsen php@emax.dk wrote: Ashley Sheridan wrote on 14/01/2010 23:36: What has been said on this thread a few times is it is not always a developer error, but a bug with the editor, which is not something that will be picked up until it occurs. Once again I love my VIm :-) (with whitespace highlight if needed) -- Kind regards Kim Emax - masterminds.dk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
Kim Madsen wrote: Mattias Thorslund wrote on 09/01/2010 02:26: A neat thing with pairing every ?php with a ? when mixed in HTML is that these are valid XML processing instructions. If your HTML satisfies XML well-formedness, your PHP document will also be valid XML. Not that I've ever had any need to process my layout templates as XML but anyway. I don't see your argument. PHP generates HTML or XML files. When you're aware of the XML tag of course you make sure the XML file generated is valid. Why would you ever add PHP code to a HTML file (other than for documentation, examples etc.)? It's not much of an argument, just an observation. And the conclusions are disappointing anyway. Certainly, if your script is designed to create XML, you'll make sure that output is valid when executed by PHP. But it is interesting to note that your PHP script file itself might qualify as valid XML under certain circumstances, in which case you could process it with an XML processor. This would let you modify the XML and still keep the PHP part of the file intact. I haven't seen a live example that might benefit from this, but I still find it interesting. The conditions that would need to be met, are that the content outside the ? and ? processing instructions must be well-formed XML, and there are places where the processing instructions aren't expected in XML. This is well-formed XML (and valid PHP): ?xml version=1.0? ?php $var = 'dynamic'; ? root attr=static ?php echo $var content from PHP\n; ? /root ?php //processing instructions can also be located after the XML content ? This is not well-formed XML (processing instruction within a tag). Note however that the output from PHP would be valid XML: ?xml version=1.0? ?php $var = 'dynamic'; ? root ?php echo attr=\$var\; ? ?php echo $var content from PHP\n; ? /root Neither is this (processing instruction within an attribute): ?xml version=1.0? ?php $var = 'dynamic'; ? root attr=?php echo $var; ? ?php echo $var content from PHP\n; ? /root And neither is this (missing opening tag for the root element): ?xml version=1.0? ?php $var = 'dynamic'; ? ?php echo root attr=\$var\\n; ? ?php echo $var content from PHP\n; ? /root A simple way to test this would be to use this: $sxe = new SimpleXMLElement('the_file.php', null, true); echo $sxe-asXML().\n; The inability to insert dynamic content into attributes without breaking the XML (ideas anyone?) does limit the usefulness of this technique, so I guess it will just remain a curiosity. Cheers, Mattias -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
Op 1/14/10 11:37 PM, Kim Madsen schreef: Ashley Sheridan wrote on 14/01/2010 23:30: What is the difference between: ? print hello PHPeople; ?WHITESPACE and ? print hello PHPeople; WHITESPACE Same shit when I look at it, a sloppy developer is what it is :-) -- Kind regards Kim Emax - masterminds.dk Plenty of differences, if you include the first one as a file, the whitespace gets sent to the browser because it is not part of the PHP, and so is assumed to be HTML. Once this happens, the headers have been sent, so you can't use different headers in your script. Hmm... you could be right. I guess I just never made that mistake :-) could be right? that implies you don't know and didn't bother to test it. I'd postulate that is sloppy. In another post you mention your reliance on your favorite editor - relying blindly on your editor to 'do the right thing' could also be considered sloppy (no tool is perfect all of the time). pretty much every php dev has run into the issue of header() calls failing due to whitespace, it's almost a rite of passage - I'd only call it a mistake if you don't bother to test your code to the extent that you actually get into a situation that you put something so obviously broken into a production env. you mention that you guess as to whether you made the mistake in question, obviously a an off the cuff remark and no worth tripping over in it's own right but it does raise an interest point, namely that only sloppy devs are satified with guess work, diligent devs either know or they don't and when they don't they take the time to research and test until they feel confident to say that they do know - rather esoteric, probably not very pragmatic, but there you have it nonetheless. you offer to different pieces of pseudo-code and call them 'the same shit when you look at it' - again there's an argument to say that's sloppy (in terms of reading code) considering they are not identical in source nor resultant output. ... same shit, different day ... or to put it another way, be very careful what you post on a techie mailing list - you never know when some pendantic SOB is going to rip you another 'one' in reply ;-). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
You could also sit on the egg. On Tue, Jan 12, 2010 at 3:41 PM, tedd tedd.sperl...@gmail.com wrote: At 3:49 PM -0500 1/12/10, Robert Cummings wrote: tedd wrote: At 5:24 PM + 1/12/10, Ashley Sheridan wrote: On Tue, 2010-01-12 at 12:22 -0500, Robert Cummings wrote: -- egg snip-its While on the subject of eggs and other non-php topics, here's a life trick. If you don't know if an egg is hard-boiled, or not, try spinning it. A hard-boiled egg will spin while a raw egg will not. I didn't bother to try, but knowing about physics and fluids, I'm going to argue that your assertion is untrue. The raw egg will spin but will quickly slow down due to the internal drag of the viscous contents that will be spinning at a much slower rate. In contrast the hard boiled egg will not have this internal drag. Cheers, Rob. Truth is relative when debating the spin of an egg. Of course, just about everything you can hold, you can spin to some degree. The point being, if you want a quick way to determine if an egg is hard-boiled, or not, then spinning it will provide convincing evidence as to which it is. The truth will be shown to those who try. Cheers, tedd -- --- 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] POLL: To add the final ? or not...
I leave ? out. I'm pretty careful about my code formatting and whitespace. It's my opinion that if I can eliminate a potential problem by not including an optional closing tag...there's really no reason why I shouldn't. -- John Corry PHP developer - 3by400, Inc http://www.3by400.com
Re: [PHP] POLL: To add the final ? or not...
On Fri, Jan 8, 2010 at 1:24 PM, Daevid Vincent dae...@daevid.com wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... So everybody, when do we get to the real discussion? Which end of an egg do we break? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
LinuxManMikeC wrote: On Fri, Jan 8, 2010 at 1:24 PM, Daevid Vincent dae...@daevid.com wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... So everybody, when do we get to the real discussion? Which end of an egg do we break? Depends upon how far away the Perl developer is when we throw it, and how much spin we put on it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
Michael A. Peters wrote: LinuxManMikeC wrote: On Fri, Jan 8, 2010 at 1:24 PM, Daevid Vincent dae...@daevid.com wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... So everybody, when do we get to the real discussion? Which end of an egg do we break? Depends upon how far away the Perl developer is when we throw it, and how much spin we put on it. You'll want to know initial release speed and drag on the egg while in flight to calculate time so you can correctly determine how many spins occur over the throw distance. 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] POLL: To add the final ? or not...
On Tue, 2010-01-12 at 12:22 -0500, Robert Cummings wrote: Michael A. Peters wrote: LinuxManMikeC wrote: On Fri, Jan 8, 2010 at 1:24 PM, Daevid Vincent dae...@daevid.com wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... So everybody, when do we get to the real discussion? Which end of an egg do we break? Depends upon how far away the Perl developer is when we throw it, and how much spin we put on it. You'll want to know initial release speed and drag on the egg while in flight to calculate time so you can correctly determine how many spins occur over the throw distance. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP There's always a chance that if thrown, the egg won't contact end-on. Has anyone thought to factor this in? Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] POLL: To add the final ? or not...
At 5:24 PM + 1/12/10, Ashley Sheridan wrote: On Tue, 2010-01-12 at 12:22 -0500, Robert Cummings wrote: -- egg snip-its While on the subject of eggs and other non-php topics, here's a life trick. If you don't know if an egg is hard-boiled, or not, try spinning it. A hard-boiled egg will spin while a raw egg will not. Cheers, tedd -- --- 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] POLL: To add the final ? or not...
On Tue, 2010-01-12 at 12:52 -0500, tedd wrote: At 5:24 PM + 1/12/10, Ashley Sheridan wrote: On Tue, 2010-01-12 at 12:22 -0500, Robert Cummings wrote: -- egg snip-its While on the subject of eggs and other non-php topics, here's a life trick. If you don't know if an egg is hard-boiled, or not, try spinning it. A hard-boiled egg will spin while a raw egg will not. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com Is that just a cruel joke to get us all covered with raw egg? :p Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] POLL: To add the final ? or not...
On Tue, Jan 12, 2010 at 05:24:06PM +, Ashley Sheridan wrote: On Tue, 2010-01-12 at 12:22 -0500, Robert Cummings wrote: Michael A. Peters wrote: LinuxManMikeC wrote: On Fri, Jan 8, 2010 at 1:24 PM, Daevid Vincent dae...@daevid.com wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... So everybody, when do we get to the real discussion? Which end of an egg do we break? Depends upon how far away the Perl developer is when we throw it, and how much spin we put on it. You'll want to know initial release speed and drag on the egg while in flight to calculate time so you can correctly determine how many spins occur over the throw distance. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP There's always a chance that if thrown, the egg won't contact end-on. Has anyone thought to factor this in? Is that an African or European egg? Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
On Tue, 2010-01-12 at 13:10 -0500, Paul M Foster wrote: On Tue, Jan 12, 2010 at 05:24:06PM +, Ashley Sheridan wrote: On Tue, 2010-01-12 at 12:22 -0500, Robert Cummings wrote: Michael A. Peters wrote: LinuxManMikeC wrote: On Fri, Jan 8, 2010 at 1:24 PM, Daevid Vincent dae...@daevid.com wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... So everybody, when do we get to the real discussion? Which end of an egg do we break? Depends upon how far away the Perl developer is when we throw it, and how much spin we put on it. You'll want to know initial release speed and drag on the egg while in flight to calculate time so you can correctly determine how many spins occur over the throw distance. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP There's always a chance that if thrown, the egg won't contact end-on. Has anyone thought to factor this in? Is that an African or European egg? Paul -- Paul M. Foster Hehe, a fan of Monty Python I see! Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] POLL: To add the final ? or not...
On Tue, Jan 12, 2010 at 06:08:59PM +, Ashley Sheridan wrote: On Tue, 2010-01-12 at 13:10 -0500, Paul M Foster wrote: On Tue, Jan 12, 2010 at 05:24:06PM +, Ashley Sheridan wrote: snip There's always a chance that if thrown, the egg won't contact end-on. Has anyone thought to factor this in? Is that an African or European egg? Paul -- Paul M. Foster Hehe, a fan of Monty Python I see! Heck yeah. I can even program in their language a little bit! Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
- Original Message - From: Paul M Foster pa...@quillandmouse.com To: Ashley Sheridan a...@ashleysheridan.co.uk Cc: php-general@lists.php.net Sent: Tuesday, January 12, 2010 7:25 PM Subject: Re: [PHP] POLL: To add the final ? or not... On Tue, Jan 12, 2010 at 06:08:59PM +, Ashley Sheridan wrote: On Tue, 2010-01-12 at 13:10 -0500, Paul M Foster wrote: On Tue, Jan 12, 2010 at 05:24:06PM +, Ashley Sheridan wrote: snip There's always a chance that if thrown, the egg won't contact end-on. Has anyone thought to factor this in? Is that an African or European egg? Paul -- Paul M. Foster Hehe, a fan of Monty Python I see! Heck yeah. I can even program in their language a little bit! Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I can't find those egg-functions really - where do I look ? REB -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
tedd wrote: At 5:24 PM + 1/12/10, Ashley Sheridan wrote: On Tue, 2010-01-12 at 12:22 -0500, Robert Cummings wrote: -- egg snip-its While on the subject of eggs and other non-php topics, here's a life trick. If you don't know if an egg is hard-boiled, or not, try spinning it. A hard-boiled egg will spin while a raw egg will not. I didn't bother to try, but knowing about physics and fluids, I'm going to argue that your assertion is untrue. The raw egg will spin but will quickly slow down due to the internal drag of the viscous contents that will be spinning at a much slower rate. In contrast the hard boiled egg will not have this internal drag. 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] POLL: To add the final ? or not...
At 3:49 PM -0500 1/12/10, Robert Cummings wrote: tedd wrote: At 5:24 PM + 1/12/10, Ashley Sheridan wrote: On Tue, 2010-01-12 at 12:22 -0500, Robert Cummings wrote: -- egg snip-its While on the subject of eggs and other non-php topics, here's a life trick. If you don't know if an egg is hard-boiled, or not, try spinning it. A hard-boiled egg will spin while a raw egg will not. I didn't bother to try, but knowing about physics and fluids, I'm going to argue that your assertion is untrue. The raw egg will spin but will quickly slow down due to the internal drag of the viscous contents that will be spinning at a much slower rate. In contrast the hard boiled egg will not have this internal drag. Cheers, Rob. Truth is relative when debating the spin of an egg. Of course, just about everything you can hold, you can spin to some degree. The point being, if you want a quick way to determine if an egg is hard-boiled, or not, then spinning it will provide convincing evidence as to which it is. The truth will be shown to those who try. Cheers, tedd -- --- 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] POLL: To add the final ? or not...
Paul M Foster wrote: I leave it off. I don't want to have to worry about which editor I'm using or whether I accidentally left some whitespace where it shouldn't be. I also use different editors in different situations, both terminal based and GUI. For instance I find Midnight Commander's internal editor quite comfortable to use but unfortunately it does leave whitespace all over the place. This discussion made me think. From now on, I will probably also leave the closing ? off in include files. If something isn't really needed then there is no rational reason to insist on using it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
Ever write a string replace function on a closing ? //somecomment here like end junk I have written some systems and gone back two to three years later and found myself having to do such. Sloppy, sure. Minimize cost to the client? Oh yeah. I keep em, and comment 'em as I feel I should. On Mon, Jan 11, 2010 at 2:24 AM, Olav olav...@xs4all.nl wrote: Paul M Foster wrote: I leave it off. I don't want to have to worry about which editor I'm using or whether I accidentally left some whitespace where it shouldn't be. I also use different editors in different situations, both terminal based and GUI. For instance I find Midnight Commander's internal editor quite comfortable to use but unfortunately it does leave whitespace all over the place. This discussion made me think. From now on, I will probably also leave the closing ? off in include files. If something isn't really needed then there is no rational reason to insist on using it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
Daevid Vincent wrote: What do you guys all do? I keep it there, and just make sure not to have white space where it should not be. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
Stuart Dallas wrote: That's a massive assumption. There are a number of editors that automatically add a blank line to the end of source files. I stand by taking the option that requires the least conscious thought from your developers - they have enough important stuff to occupy their brain that remembering to make sure there is no whitespace at the end of their source files should not be one of them. -Stuart I would suggest getting a text editor that doesn't do that then. There are text editors that don't. There also are e-mail clients that properly wrap the body content before sending ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
On 10 Jan 2010, at 14:44, Michael A. Peters wrote: Stuart Dallas wrote: That's a massive assumption. There are a number of editors that automatically add a blank line to the end of source files. I stand by taking the option that requires the least conscious thought from your developers - they have enough important stuff to occupy their brain that remembering to make sure there is no whitespace at the end of their source files should not be one of them. -Stuart I would suggest getting a text editor that doesn't do that then. There are text editors that don't. There also are e-mail clients that properly wrap the body content before sending ;) I would rather not have a requirement on the tools my developers use which potentially (and usually) improves their productivity than impose a requirement that has no apparent benefit outside of XML files, and even then the benefit is irrelevant since it's already a file that contains both code and XML. And if you don't like the way my emails look feel free to forward them into a black hole, I'll be fine with that. Alternatively talk to Apple and get them to change their Mail app to your idea or properly. Either way I'm going to get back to worrying about things that matter. ;) -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
Stuart Dallas wrote: On 10 Jan 2010, at 14:44, Michael A. Peters wrote: Stuart Dallas wrote: That's a massive assumption. There are a number of editors that automatically add a blank line to the end of source files. I stand by taking the option that requires the least conscious thought from your developers - they have enough important stuff to occupy their brain that remembering to make sure there is no whitespace at the end of their source files should not be one of them. -Stuart I would suggest getting a text editor that doesn't do that then. There are text editors that don't. There also are e-mail clients that properly wrap the body content before sending ;) I would rather not have a requirement on the tools my developers use which potentially (and usually) improves their productivity than impose a requirement that has no apparent benefit outside of XML files, and even then the benefit is irrelevant since it's already a file that contains both code and XML. And if you don't like the way my emails look feel free to forward them into a black hole, I'll be fine with that. Alternatively talk to Apple and get them to change their Mail app to your idea or properly. Either way I'm going to get back to worrying about things that matter. ;) -Stuart I suspect that you just don't word wrap enabled in your Mail.app preferences. That use to be an option anyway (I haven't used OS X since 10.1) Anyway, I didn't fix the wrap on this before replying just to show what happens. Each paragraph end up as a big long line instead of having a break put in. Ah well, doesn't bother me as much as HTML mail to lists does ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
Stuart Dallas wrote: That's a massive assumption. There are a number of editors that automatically add a blank line to the end of source files. A single \n after the final ? doesn't matter anyways. Even if the following example was two different files where the second included the first, it would still have the same results. Simple test: CONTENTS ?php ? ?php echo (headers_sent() ? 'Yes' : 'No'); ? EOF No, as is, this will return 'No'. But if you place /ANY/ character between the ? ?php including a newline, space, tab, etc... it will send the headers. So, basically saying that in this particular case ??php === ?\n?php With all that said, you CAN have a \n at the end of you file directly after the ?. But, you better make sure that nothing else is there along with it. Jim Lucas -Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
On Sun, 2010-01-10 at 08:52 -0800, Jim Lucas wrote: Stuart Dallas wrote: That's a massive assumption. There are a number of editors that automatically add a blank line to the end of source files. A single \n after the final ? doesn't matter anyways. Even if the following example was two different files where the second included the first, it would still have the same results. Simple test: CONTENTS ?php ? ?php echo (headers_sent() ? 'Yes' : 'No'); ? EOF No, as is, this will return 'No'. But if you place /ANY/ character between the ? ?php including a newline, space, tab, etc... it will send the headers. So, basically saying that in this particular case ??php === ?\n?php With all that said, you CAN have a \n at the end of you file directly after the ?. But, you better make sure that nothing else is there along with it. Jim Lucas -Stuart Or if you're using a multibyte encoding in your file which isn't correctly interpretted... Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] POLL: To add the final ? or not...
On Sun, Jan 10, 2010 at 06:41:19AM -0800, Michael A. Peters wrote: Daevid Vincent wrote: What do you guys all do? I leave it off. I don't want to have to worry about which editor I'm using or whether I accidentally left some whitespace where it shouldn't be. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
On Fri, 2010-01-08 at 12:24 -0800, Daevid Vincent wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... To be honest, I am the lead, and I could pull rank and be done with the discussion, however I don't like to be that way. I would rather do the right thing. If my way of thinking is old-school (I've been coding since PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd rather adopt that, despite how icky it makes me feel to leave an unclosed ?php just dangling and alone, all sad-like. In my mind, nobody gets left behind! :) Is there ANY side-effects to leaving the end ? off? Is it any more work for the compiler? And yes I know computers are hella-fast and all that, but I come from the gaming industry where squeeking out an extra FPS matters, and shaving off 0.01s per row of data in a table matters if you have more than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso -- just try to talk for 10 seconds straight without a pause. Or sit there and stare at a screen for 10 seconds! If the main argument is that it's to prevent white-space after the code, then most modern editors that I'm aware of will automatically trim white-space (or have a setting to do so). Plus this is ONLY a factor when you're trying to output a header and things like that. In 90% of your code, you don't deal with that. It's also obvious enough when you have an extra character/space because PHP pukes on the screen and TELLS you something about blah blah sent before header output or something to that effect. What do you guys all do? I also created a poll here http://www.rapidpoll.net/arc1opy -Original Message- From: Co-worker To: Daevid Vincent Actually, Zend states that you should omit the final ? on include pages. There is no harm in the action, and it prevents you from accidentally adding white space after the tag which will break the code. http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm l -Original Message- From: Daevid Vincent To: Co-worker Please DO include the final ? I noticed on several of your files that you have purposely omitted it. Yes, I know the files work without them, but it makes things easier to see the pairings for matching ?php . Plus it keeps things consistent and I'm not a big fan of special cases as this is, especially if it's a bad habit to get into since in all other cases it's required except this one lazy one. If you are concerned about white space sending in a header or something, well then just make sure there isn't any. I've had no problems and it makes you a more careful coder. Thanks, Daevid. I always include the final ? for neatness, and have had no problems doing so. There is an argument that leaving off the ? prevents multibyte end of line markers from causing problems with headers being sent when the PHP file is being included in another, but I've not had this problem on the text editors I use. That said, some systems do have coding style conventions regarding them, so if your code is to be included in any of those, then maybe it's best following their conventions. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] POLL: To add the final ? or not...
http://framework.zend.com/manual/en/coding-standard.html#coding-standard.overview.scope This document provides guidelines for code formatting and documentation to individuals and teams contributing to Zend Framework. So as far as anything other than code being contributed to Zend Framework, its just a suggestion. For your programming team, you're the boss, you make the decision. The only benefit I see is preventing the white space mistake (as your co-worker's quote mentioned), but I agree with you on that point. Just don't put any white space there... moron... :-) Its an inconsequential option, pull rank, get back to work. On Fri, Jan 8, 2010 at 1:24 PM, Daevid Vincent dae...@daevid.com wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... To be honest, I am the lead, and I could pull rank and be done with the discussion, however I don't like to be that way. I would rather do the right thing. If my way of thinking is old-school (I've been coding since PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd rather adopt that, despite how icky it makes me feel to leave an unclosed ?php just dangling and alone, all sad-like. In my mind, nobody gets left behind! :) Is there ANY side-effects to leaving the end ? off? Is it any more work for the compiler? And yes I know computers are hella-fast and all that, but I come from the gaming industry where squeeking out an extra FPS matters, and shaving off 0.01s per row of data in a table matters if you have more than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso -- just try to talk for 10 seconds straight without a pause. Or sit there and stare at a screen for 10 seconds! If the main argument is that it's to prevent white-space after the code, then most modern editors that I'm aware of will automatically trim white-space (or have a setting to do so). Plus this is ONLY a factor when you're trying to output a header and things like that. In 90% of your code, you don't deal with that. It's also obvious enough when you have an extra character/space because PHP pukes on the screen and TELLS you something about blah blah sent before header output or something to that effect. What do you guys all do? I also created a poll here http://www.rapidpoll.net/arc1opy -Original Message- From: Co-worker To: Daevid Vincent Actually, Zend states that you should omit the final ? on include pages. There is no harm in the action, and it prevents you from accidentally adding white space after the tag which will break the code. http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm l -Original Message- From: Daevid Vincent To: Co-worker Please DO include the final ? I noticed on several of your files that you have purposely omitted it. Yes, I know the files work without them, but it makes things easier to see the pairings for matching ?php . Plus it keeps things consistent and I'm not a big fan of special cases as this is, especially if it's a bad habit to get into since in all other cases it's required except this one lazy one. If you are concerned about white space sending in a header or something, well then just make sure there isn't any. I've had no problems and it makes you a more careful coder. Thanks, Daevid. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
if you use the newest PDT, you will find that a new php file has no final ? I vote for your co-worker [?] On Fri, Jan 8, 2010 at 3:49 PM, LinuxManMikeC linuxmanmi...@gmail.comwrote: http://framework.zend.com/manual/en/coding-standard.html#coding-standard.overview.scope This document provides guidelines for code formatting and documentation to individuals and teams contributing to Zend Framework. So as far as anything other than code being contributed to Zend Framework, its just a suggestion. For your programming team, you're the boss, you make the decision. The only benefit I see is preventing the white space mistake (as your co-worker's quote mentioned), but I agree with you on that point. Just don't put any white space there... moron... :-) Its an inconsequential option, pull rank, get back to work. On Fri, Jan 8, 2010 at 1:24 PM, Daevid Vincent dae...@daevid.com wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... To be honest, I am the lead, and I could pull rank and be done with the discussion, however I don't like to be that way. I would rather do the right thing. If my way of thinking is old-school (I've been coding since PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd rather adopt that, despite how icky it makes me feel to leave an unclosed ?php just dangling and alone, all sad-like. In my mind, nobody gets left behind! :) Is there ANY side-effects to leaving the end ? off? Is it any more work for the compiler? And yes I know computers are hella-fast and all that, but I come from the gaming industry where squeeking out an extra FPS matters, and shaving off 0.01s per row of data in a table matters if you have more than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso -- just try to talk for 10 seconds straight without a pause. Or sit there and stare at a screen for 10 seconds! If the main argument is that it's to prevent white-space after the code, then most modern editors that I'm aware of will automatically trim white-space (or have a setting to do so). Plus this is ONLY a factor when you're trying to output a header and things like that. In 90% of your code, you don't deal with that. It's also obvious enough when you have an extra character/space because PHP pukes on the screen and TELLS you something about blah blah sent before header output or something to that effect. What do you guys all do? I also created a poll here http://www.rapidpoll.net/arc1opy -Original Message- From: Co-worker To: Daevid Vincent Actually, Zend states that you should omit the final ? on include pages. There is no harm in the action, and it prevents you from accidentally adding white space after the tag which will break the code. http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm l -Original Message- From: Daevid Vincent To: Co-worker Please DO include the final ? I noticed on several of your files that you have purposely omitted it. Yes, I know the files work without them, but it makes things easier to see the pairings for matching ?php . Plus it keeps things consistent and I'm not a big fan of special cases as this is, especially if it's a bad habit to get into since in all other cases it's required except this one lazy one. If you are concerned about white space sending in a header or something, well then just make sure there isn't any. I've had no problems and it makes you a more careful coder. Thanks, Daevid. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
On 8 Jan 2010, at 20:49, LinuxManMikeC wrote: http://framework.zend.com/manual/en/coding-standard.html#coding-standard.overview.scope This document provides guidelines for code formatting and documentation to individuals and teams contributing to Zend Framework. So as far as anything other than code being contributed to Zend Framework, its just a suggestion. For your programming team, you're the boss, you make the decision. The only benefit I see is preventing the white space mistake (as your co-worker's quote mentioned), but I agree with you on that point. Just don't put any white space there... moron... :-) Its an inconsequential option, pull rank, get back to work. My opinion is that it's not an inconsequential option. Putting it in can cause issues, leaving it out does nothing but rub against some people's sense of neatness and order. Given the choice I'll always vote for the one that doesn't cause issues - I'd rather have people a tiny bit uncomfortable with not having it there than finding out there's a bit of whitespace at the end of a file when it could be in one of thousands. But maybe that's just me. -Stuart -- http://stut.net/ On Fri, Jan 8, 2010 at 1:24 PM, Daevid Vincent dae...@daevid.com wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... To be honest, I am the lead, and I could pull rank and be done with the discussion, however I don't like to be that way. I would rather do the right thing. If my way of thinking is old-school (I've been coding since PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd rather adopt that, despite how icky it makes me feel to leave an unclosed ?php just dangling and alone, all sad-like. In my mind, nobody gets left behind! :) Is there ANY side-effects to leaving the end ? off? Is it any more work for the compiler? And yes I know computers are hella-fast and all that, but I come from the gaming industry where squeeking out an extra FPS matters, and shaving off 0.01s per row of data in a table matters if you have more than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso -- just try to talk for 10 seconds straight without a pause. Or sit there and stare at a screen for 10 seconds! If the main argument is that it's to prevent white-space after the code, then most modern editors that I'm aware of will automatically trim white-space (or have a setting to do so). Plus this is ONLY a factor when you're trying to output a header and things like that. In 90% of your code, you don't deal with that. It's also obvious enough when you have an extra character/space because PHP pukes on the screen and TELLS you something about blah blah sent before header output or something to that effect. What do you guys all do? I also created a poll here http://www.rapidpoll.net/arc1opy -Original Message- From: Co-worker To: Daevid Vincent Actually, Zend states that you should omit the final ? on include pages. There is no harm in the action, and it prevents you from accidentally adding white space after the tag which will break the code. http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm l -Original Message- From: Daevid Vincent To: Co-worker Please DO include the final ? I noticed on several of your files that you have purposely omitted it. Yes, I know the files work without them, but it makes things easier to see the pairings for matching ?php . Plus it keeps things consistent and I'm not a big fan of special cases as this is, especially if it's a bad habit to get into since in all other cases it's required except this one lazy one. If you are concerned about white space sending in a header or something, well then just make sure there isn't any. I've had no problems and it makes you a more careful coder. Thanks, Daevid. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
On Fri, 2010-01-08 at 21:30 +, Stuart Dallas wrote: On 8 Jan 2010, at 20:49, LinuxManMikeC wrote: http://framework.zend.com/manual/en/coding-standard.html#coding-standard.overview.scope This document provides guidelines for code formatting and documentation to individuals and teams contributing to Zend Framework. So as far as anything other than code being contributed to Zend Framework, its just a suggestion. For your programming team, you're the boss, you make the decision. The only benefit I see is preventing the white space mistake (as your co-worker's quote mentioned), but I agree with you on that point. Just don't put any white space there... moron... :-) Its an inconsequential option, pull rank, get back to work. My opinion is that it's not an inconsequential option. Putting it in can cause issues, leaving it out does nothing but rub against some people's sense of neatness and order. Given the choice I'll always vote for the one that doesn't cause issues - I'd rather have people a tiny bit uncomfortable with not having it there than finding out there's a bit of whitespace at the end of a file when it could be in one of thousands. But maybe that's just me. -Stuart -- http://stut.net/ On Fri, Jan 8, 2010 at 1:24 PM, Daevid Vincent dae...@daevid.com wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... To be honest, I am the lead, and I could pull rank and be done with the discussion, however I don't like to be that way. I would rather do the right thing. If my way of thinking is old-school (I've been coding since PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd rather adopt that, despite how icky it makes me feel to leave an unclosed ?php just dangling and alone, all sad-like. In my mind, nobody gets left behind! :) Is there ANY side-effects to leaving the end ? off? Is it any more work for the compiler? And yes I know computers are hella-fast and all that, but I come from the gaming industry where squeeking out an extra FPS matters, and shaving off 0.01s per row of data in a table matters if you have more than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso -- just try to talk for 10 seconds straight without a pause. Or sit there and stare at a screen for 10 seconds! If the main argument is that it's to prevent white-space after the code, then most modern editors that I'm aware of will automatically trim white-space (or have a setting to do so). Plus this is ONLY a factor when you're trying to output a header and things like that. In 90% of your code, you don't deal with that. It's also obvious enough when you have an extra character/space because PHP pukes on the screen and TELLS you something about blah blah sent before header output or something to that effect. What do you guys all do? I also created a poll here http://www.rapidpoll.net/arc1opy -Original Message- From: Co-worker To: Daevid Vincent Actually, Zend states that you should omit the final ? on include pages. There is no harm in the action, and it prevents you from accidentally adding white space after the tag which will break the code. http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm l -Original Message- From: Daevid Vincent To: Co-worker Please DO include the final ? I noticed on several of your files that you have purposely omitted it. Yes, I know the files work without them, but it makes things easier to see the pairings for matching ?php . Plus it keeps things consistent and I'm not a big fan of special cases as this is, especially if it's a bad habit to get into since in all other cases it's required except this one lazy one. If you are concerned about white space sending in a header or something, well then just make sure there isn't any. I've had no problems and it makes you a more careful coder. Thanks, Daevid. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If someone is leaving whitespace all over the place that's causing those sorts of problems, then their use of ? is the least of your problems, as I suspect their code layout is probably atrocious! Getting code laid out correctly is far more important an issue than a closing ?, and when it's done correctly, you avoid a lot of problems, more than a closing ? can cause. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] POLL: To add the final ? or not...
On 8 Jan 2010, at 21:38, Ashley Sheridan wrote: On Fri, 2010-01-08 at 21:30 +, Stuart Dallas wrote: On 8 Jan 2010, at 20:49, LinuxManMikeC wrote: http://framework.zend.com/manual/en/coding-standard.html#coding-standard.overview.scope This document provides guidelines for code formatting and documentation to individuals and teams contributing to Zend Framework. So as far as anything other than code being contributed to Zend Framework, its just a suggestion. For your programming team, you're the boss, you make the decision. The only benefit I see is preventing the white space mistake (as your co-worker's quote mentioned), but I agree with you on that point. Just don't put any white space there... moron... :-) Its an inconsequential option, pull rank, get back to work. My opinion is that it's not an inconsequential option. Putting it in can cause issues, leaving it out does nothing but rub against some people's sense of neatness and order. Given the choice I'll always vote for the one that doesn't cause issues - I'd rather have people a tiny bit uncomfortable with not having it there than finding out there's a bit of whitespace at the end of a file when it could be in one of thousands. But maybe that's just me. -Stuart -- http://stut.net/ On Fri, Jan 8, 2010 at 1:24 PM, Daevid Vincent dae...@daevid.com wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... To be honest, I am the lead, and I could pull rank and be done with the discussion, however I don't like to be that way. I would rather do the right thing. If my way of thinking is old-school (I've been coding since PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd rather adopt that, despite how icky it makes me feel to leave an unclosed ?php just dangling and alone, all sad-like. In my mind, nobody gets left behind! :) Is there ANY side-effects to leaving the end ? off? Is it any more work for the compiler? And yes I know computers are hella-fast and all that, but I come from the gaming industry where squeeking out an extra FPS matters, and shaving off 0.01s per row of data in a table matters if you have more than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso -- just try to talk for 10 seconds straight without a pause. Or sit there and stare at a screen for 10 seconds! If the main argument is that it's to prevent white-space after the code, then most modern editors that I'm aware of will automatically trim white-space (or have a setting to do so). Plus this is ONLY a factor when you're trying to output a header and things like that. In 90% of your code, you don't deal with that. It's also obvious enough when you have an extra character/space because PHP pukes on the screen and TELLS you something about blah blah sent before header output or something to that effect. What do you guys all do? I also created a poll here http://www.rapidpoll.net/arc1opy -Original Message- From: Co-worker To: Daevid Vincent Actually, Zend states that you should omit the final ? on include pages. There is no harm in the action, and it prevents you from accidentally adding white space after the tag which will break the code. http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm l -Original Message- From: Daevid Vincent To: Co-worker Please DO include the final ? I noticed on several of your files that you have purposely omitted it. Yes, I know the files work without them, but it makes things easier to see the pairings for matching ?php . Plus it keeps things consistent and I'm not a big fan of special cases as this is, especially if it's a bad habit to get into since in all other cases it's required except this one lazy one. If you are concerned about white space sending in a header or something, well then just make sure there isn't any. I've had no problems and it makes you a more careful coder. Thanks, Daevid. -- PHP General Mailing List ( http://www.php.net/ ) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List ( http://www.php.net/ ) To unsubscribe, visit: http://www.php.net/unsub.php If someone is leaving whitespace all over the place that's causing those sorts of problems, then their use of ? is the least of your problems, as I suspect their code layout is probably atrocious! Getting code laid out correctly is far more important an issue than a closing ?, and when it's done correctly, you avoid a lot of problems, more than a closing ? can cause. That's a massive assumption. There are a number of editors that automatically add a blank line to the end of source files. I stand by taking the option that requires the least conscious thought from
Re: [PHP] POLL: To add the final ? or not...
At 12:24 PM -0800 1/8/10, Daevid Vincent wrote: What do you guys all do? I always close my code. I have never had a problem in doing so. I shall continue to close my code until it trips me up. At such time, I'll figure out what the problem is and fix it. Then I'll probably still close my code as is my habit. However, I think there are more important things to ponder. Cheers, tedd -- --- 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] POLL: To add the final ? or not...
Hadn't paid much attention to the issue until reading a previous discussion on the topic, here on this list. After that, I decided to be consistent and leave the closing ? out in all include files. To my eyes, ? means look there is more content coming, which seems kind of silly when there isn't. A neat thing with pairing every ?php with a ? when mixed in HTML is that these are valid XML processing instructions. If your HTML satisfies XML well-formedness, your PHP document will also be valid XML. Not that I've ever had any need to process my layout templates as XML but anyway. Cheers, Mattias Daevid Vincent wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... To be honest, I am the lead, and I could pull rank and be done with the discussion, however I don't like to be that way. I would rather do the right thing. If my way of thinking is old-school (I've been coding since PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd rather adopt that, despite how icky it makes me feel to leave an unclosed ?php just dangling and alone, all sad-like. In my mind, nobody gets left behind! :) Is there ANY side-effects to leaving the end ? off? Is it any more work for the compiler? And yes I know computers are hella-fast and all that, but I come from the gaming industry where squeeking out an extra FPS matters, and shaving off 0.01s per row of data in a table matters if you have more than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso -- just try to talk for 10 seconds straight without a pause. Or sit there and stare at a screen for 10 seconds! If the main argument is that it's to prevent white-space after the code, then most modern editors that I'm aware of will automatically trim white-space (or have a setting to do so). Plus this is ONLY a factor when you're trying to output a header and things like that. In 90% of your code, you don't deal with that. It's also obvious enough when you have an extra character/space because PHP pukes on the screen and TELLS you something about blah blah sent before header output or something to that effect. What do you guys all do? I also created a poll here http://www.rapidpoll.net/arc1opy -Original Message- From: Co-worker To: Daevid Vincent Actually, Zend states that you should omit the final ? on include pages. There is no harm in the action, and it prevents you from accidentally adding white space after the tag which will break the code. http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm l -Original Message- From: Daevid Vincent To: Co-worker Please DO include the final ? I noticed on several of your files that you have purposely omitted it. Yes, I know the files work without them, but it makes things easier to see the pairings for matching ?php . Plus it keeps things consistent and I'm not a big fan of special cases as this is, especially if it's a bad habit to get into since in all other cases it's required except this one lazy one. If you are concerned about white space sending in a header or something, well then just make sure there isn't any. I've had no problems and it makes you a more careful coder. Thanks, Daevid. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
I would leave this to personal preference, whether there is a closing ? or not wouldn't bother me. I could argue both ways: Pro: You should put a final ? for neatness and XML compatibility. Con: It makes the script fractionally slower because 2 more characters have to be processed and there might be issues with the header when it's already sent. I've had that problem before and it's really annoying. Regards, Tim ++Tim Hinnerk Heuer++ http://www.ihostnz.com 2010/1/9 Mattias Thorslund matt...@thorslund.us Hadn't paid much attention to the issue until reading a previous discussion on the topic, here on this list. After that, I decided to be consistent and leave the closing ? out in all include files. To my eyes, ? means look there is more content coming, which seems kind of silly when there isn't. A neat thing with pairing every ?php with a ? when mixed in HTML is that these are valid XML processing instructions. If your HTML satisfies XML well-formedness, your PHP document will also be valid XML. Not that I've ever had any need to process my layout templates as XML but anyway. Cheers, Mattias Daevid Vincent wrote: I'm having a debate with a co-worker about adding the final ? on a PHP page... To be honest, I am the lead, and I could pull rank and be done with the discussion, however I don't like to be that way. I would rather do the right thing. If my way of thinking is old-school (I've been coding since PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd rather adopt that, despite how icky it makes me feel to leave an unclosed ?php just dangling and alone, all sad-like. In my mind, nobody gets left behind! :) Is there ANY side-effects to leaving the end ? off? Is it any more work for the compiler? And yes I know computers are hella-fast and all that, but I come from the gaming industry where squeeking out an extra FPS matters, and shaving off 0.01s per row of data in a table matters if you have more than 100 rows. A 1 second wait IS noticeable and a 10 second is even moreso -- just try to talk for 10 seconds straight without a pause. Or sit there and stare at a screen for 10 seconds! If the main argument is that it's to prevent white-space after the code, then most modern editors that I'm aware of will automatically trim white-space (or have a setting to do so). Plus this is ONLY a factor when you're trying to output a header and things like that. In 90% of your code, you don't deal with that. It's also obvious enough when you have an extra character/space because PHP pukes on the screen and TELLS you something about blah blah sent before header output or something to that effect. What do you guys all do? I also created a poll here http://www.rapidpoll.net/arc1opy -Original Message- From: Co-worker To: Daevid Vincent Actually, Zend states that you should omit the final ? on include pages. There is no harm in the action, and it prevents you from accidentally adding white space after the tag which will break the code. http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm l -Original Message- From: Daevid Vincent To: Co-worker Please DO include the final ? I noticed on several of your files that you have purposely omitted it. Yes, I know the files work without them, but it makes things easier to see the pairings for matching ?php . Plus it keeps things consistent and I'm not a big fan of special cases as this is, especially if it's a bad habit to get into since in all other cases it's required except this one lazy one. If you are concerned about white space sending in a header or something, well then just make sure there isn't any. I've had no problems and it makes you a more careful coder. Thanks, Daevid. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POLL: To add the final ? or not...
Mattias Thorslund wrote: Hadn't paid much attention to the issue until reading a previous discussion on the topic, here on this list. After that, I decided to be consistent and leave the closing ? out in all include files. To my eyes, ? means look there is more content coming, which seems kind of silly when there isn't. For mixed HTML/PHP files I add the ? but for source only files I leave it off. 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] POLL: To add the final ? or not...
tedd wrote: At 12:24 PM -0800 1/8/10, Daevid Vincent wrote: What do you guys all do? I always close my code. I have never had a problem in doing so. I shall continue to close my code until it trips me up. At such time, I'll figure out what the problem is and fix it. Then I'll probably still close my code as is my habit. However, I think there are more important things to ponder. +1 /Per -- Per Jessen, Zürich (-4.4°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php