Re: Re: if syntax

From: Date: Fri, 12 Jul 2002 17:58:24 +0000
Subject: Re: Re: if syntax
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-107404@lists.php.net to get a copy of this message
"Mike Ford" <M.Ford@lmu.ac.uk> wrote in message news:7E070107F405BA4790C43526CC4985A10132AB8B@lis-exchange3.lmu.ac.uk... > > -----Original Message----- > > From: Chris Earle [mailto:chris@earleweb.com] > > Sent: 11 July 2002 18:28 > > To: php-general@lists.php.net > > Subject: Re: [PHP] Re: if syntax > > > > > > > when it would be just as easy, and more functional, to > > write this (even > > > saves a few characters, too!): > > > > > > if (x): > > > while (y): > > > ... > > > endwhile; > > > ... > > > endif; > > > > You're adding characters... > > > > "{" + "}" opposed to ":" + "endif;" > > No, no, no! Look again -- I was contrasting this with: > > if (x) { > while (y) { > ... > } // end while > ... > } // end if > > which I see quite often in other people's scripts. > > Then the difference is " {" and "} // end if" as opposed to ":" > and > "endif;", and indeed you are saving characters -- and it's more functional, > because the PHP processor is getting to check the end* statements match the > correct block opener, rather than just matching back to the next unclosed > "{" regardless of whether it's on an appropriate block opener or not. To > me, this is such a huge advantage that I just can't understand why people > insist on sticking with the all-braces style, and that's regardless of the > fact that I just think it's more readable. Oh, just as the other guy said, I don't comment my braces because I tab in everything evenly (each if is another tab with the nested code tabed one further). I do comment my functions end braces because they can get pretty big and they're all at the same level of tabbing. I think that most people (like me) use it because of their backgrounds in other programming languages. I learned PHP after I was doing a lot of C++ work ... so it came very naturely. > Cheers! > > Mike > > --------------------------------------------------------------------- > Mike Ford, Electronic Information Services Adviser, > Learning Support Services, Learning & Information Services, > JG125, James Graham Building, Leeds Metropolitan University, > Beckett Park, LEEDS, LS6 3QS, United Kingdom > Email: m.ford@lmu.ac.uk > Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#107404) next »