PHP Hackery
I just found this article called Five Things You Didn’t Know You Could Do with PHP. An interesting read for any PHP hackers out there.
The only one I didn’t know about was #1- apparently this is legal:
< ?php
switch (TRUE) {
case ($age < 16):
echo 'You cannot drive.';
break;
case ($age < 18):
echo 'You cannot vote.';
break;
case ($age < 21):
echo 'You cannot drink.';
break;
case ($age > 65):
echo 'You should be retired.';
break;
default:
echo 'Work, work, work...';
break;
?}
?>
Saves a bit of space/typing versus if/elseif/else, but other than that I’m not sure how useful it is.

March 31st, 2005 at 12:06 am
Woah, that custom error handler kicks so much butt!