This fails the "Make PHP code easier to read" test I think. But it passes the "I'm a lazy programmer" test with flying colors! ;-)
I mean seriously, what real value does this add to the language? Its just syntactic sugar to save yourself a few keystrokes. On 5/3/07, Andrew Brampton <[EMAIL PROTECTED]> wrote:
----- Original Message ----- > On Sat, April 28, 2007 1:03 pm, Pelle Ravn Rosfeldt wrote: >> Is it possible to make a "while" with a "else"-statement in PHP6? >> I know that it's not the first time this subject is up, but my >> research >> shows that a lot of people miss it. Including me. >> >> Here's an example of what I mean: >> --------------------- >> <? >> $i = 1; >> while ($i <= 10) { >> echo $i++; >> } else { >> echo "The while couldn't be executed!"; >> } >> ?> >> --------------------- I have wanted to use this kind of syntax a couple of times, for example: <?php while ($line = mysql_fetch_array(...)) { echo $line; } else { echo 'Sorry no records'; } ?> Otherwise I would write the above code as a while + a if. However I'm unsure if this syntax should be put into PHP, but I thought I'll just post a example of when I would use it. thanks Andrew -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php