Monday, April 16, 2007

endforeach

I never knew before this day that PHP offered an alternate syntax for closing blocks of code. The standard syntax which we are used to and comes from the C programming language is opening and closing braces: { and }. For instance:

foreach($list as $item)
{
    echo $item;
}

The alternative syntax I just knew about today is like this:
foreach($list as $item):
    echo $item;
endforeach
Quite cool. Other control statements as well can be closed in a similar manner. Check out the alternative syntax for control structures from the PHP manual.