RE: Fw: [PHP] debuging and getting mor information about failures
| From: | Ford, Mike [LSS] | Date: | Tue, 29 Jul 2003 17:59:51 +0000 |
| Subject: | RE: Fw: [PHP] debuging and getting mor information about failures | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-157357@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Chris W. Parker [mailto:cparker@swatgear.com]
> Sent: 29 July 2003 17:56
[...snip...]
> As opposed to the much easier to read (and line up curly
> braces) method:
>
> function doit()
> {
> for()
> {
> if()
> }
> ...
> }
> else
> {
> ...
> }
> }
> }
Or the (IMVHO) even easier to read, even easier to match up, and producing more focussed error
messages:
function doit()
{
for():
if():
...
else:
...
endif;
endfor;
}
And yes, this is valid PHP -- it's the alternative control-structure syntax that is mentioned
throughout the control structures section of the manual. The beauty here is that if you
accidentally leave out (say) the endif, you'll get an error at the endfor (because the parser
is expecting an endif!), not waaaay down at the bottom of the file when it just knows there's
an unclosed brace from somewhere or other.
I know the braces vs. end-token debate is almost on the scale of a holy war, and I admit to hating
the curly-brace style with a passion, but when I see code like this:
function doit()
{
for()
{
if()
}
...
}
else
{
...
} // if
} // for
}
I wonder why the heck the author didn't just go for the alternative syntax with proper
end-tokens and get the added value they deliver.
OK, I'll step back off my soap-box now ... ;)
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