alternative syntax for do...while

php.internals

Marc Richards

22 years ago
I guess this is too late for 5.0, and I feel like there is bound to be opposition, but this has been bugging me for a while, so I figured I would ask. I use the alternative syntax for control structures almost exclusively within my HTML code but I have to revert to braces for do...while. Why can't we do this? <? do: ?> <tr> <td><?= $s_array['name'] ?></td> <td><?= $s_array['classyear'] ?></td> <td><?= $s_array['status'] ?></td> </tr> <? while ($s_array = mysql_fetch_array($search_results): ?> <? enddowhile ?> It is a little cumbersome, but at least I can keep my syntax consistent. Are there parser related problems? Marc

Thomas Seifert

22 years ago
On Mon, 12 Jul 2004 21:53:51 -0400, Marc Richards wrote:
> <? do: ?> > <tr> > <td><?= $s_array['name'] ?></td> > <td><?= $s_array['classyear'] ?></td> > <td><?= $s_array['status'] ?></td> > </tr> > <? while ($s_array = mysql_fetch_array($search_results): ?> > <? enddowhile ?> >
This looks like a good case to use a real template-engine. thomas

Marc Richards

22 years ago
Thomas Seifert wrote:
> On Mon, 12 Jul 2004 21:53:51 -0400, Marc Richards wrote: > > >><? do: ?> >><tr> >> <td><?= $s_array['name'] ?></td> >> <td><?= $s_array['classyear'] ?></td> >> <td><?= $s_array['status'] ?></td> >></tr> >><? while ($s_array = mysql_fetch_array($search_results): ?> >><? enddowhile ?> >> > > > This looks like a good case to use a real template-engine. >
Huh? Why would you use a template engine if the features you are looking for already exist in the language. You think I should use a template engine just for do while? Marc

Red Wingate

22 years ago
Marc Richards wrote:
> I guess this is too late for 5.0, and I feel like there is bound to be > opposition, but this has been bugging me for a while, so I figured I > would ask. > > I use the alternative syntax for control structures almost exclusively > within my HTML code but I have to revert to braces for do...while. Why > can't we do this? > > > <? do: ?> > <tr> > <td><?= $s_array['name'] ?></td> > <td><?= $s_array['classyear'] ?></td> > <td><?= $s_array['status'] ?></td> > </tr> > <? while ($s_array = mysql_fetch_array($search_results): ?> > <? enddowhile ?> > > > It is a little cumbersome, but at least I can keep my syntax consistent. > Are there parser related problems? > > > Marc
<?php do { ?> <tr> <td><?= $s_array['name'] ?></td> <td><?= $s_array['classyear'] ?></td> <td><?= $s_array['status'] ?></td> </tr> <?php } while ($s_array = mysql_fetch_array($search_results); ?> is much shorter, ain't it ?

Marc Richards

22 years ago
Red Wingate wrote:
> Marc Richards wrote: > > >>I guess this is too late for 5.0, and I feel like there is bound to be >>opposition, but this has been bugging me for a while, so I figured I >>would ask. >> >>I use the alternative syntax for control structures almost exclusively >>within my HTML code but I have to revert to braces for do...while. Why >>can't we do this? >> >> >><? do: ?> >><tr> >> <td><?= $s_array['name'] ?></td> >> <td><?= $s_array['classyear'] ?></td> >> <td><?= $s_array['status'] ?></td> >></tr> >><? while ($s_array = mysql_fetch_array($search_results): ?> >><? enddowhile ?> >> >> >>It is a little cumbersome, but at least I can keep my syntax consistent. >> Are there parser related problems? >> >> >>Marc > > > <?php do { ?> > <tr> > <td><?= $s_array['name'] ?></td> > <td><?= $s_array['classyear'] ?></td> > <td><?= $s_array['status'] ?></td> > </tr> > <?php } while ($s_array = mysql_fetch_array($search_results); ?> > > is much shorter, ain't it ?
It is, and that is what I currently do, but <?php if ($x == TRUE){ ?> <tr> <td><?= $s_array['name'] ?></td> <td><?= $s_array['classyear'] ?></td> <td><?= $s_array['status'] ?></td> </tr> <? } ?> Is generally less readable (especially in a large page) than: <?php if ($x == TRUE): ?> <tr> <td><?= $s_array['name'] ?></td> <td><?= $s_array['classyear'] ?></td> <td><?= $s_array['status'] ?></td> </tr> <? endif ?> And I was looking for some consistency...not necessarily brevity. Marc

Ferdinand Beyer

22 years ago
On 13 Jul 2004 at 11:34, Marc Richards wrote:
> It is, and that is what I currently do, but > > > <?php if ($x == TRUE){ ?> > <tr> > <td><?= $s_array['name'] ?></td> > <td><?= $s_array['classyear'] ?></td> > <td><?= $s_array['status'] ?></td> > </tr> > <? } ?> > > > Is generally less readable (especially in a large page) than: > > <?php if ($x == TRUE): ?> > <tr> > <td><?= $s_array['name'] ?></td> > <td><?= $s_array['classyear'] ?></td> > <td><?= $s_array['status'] ?></td> > </tr> > <? endif ?>
If you want readability, try using comments! <? if ($x == TRUE) { ?> <tr> <td><?= $s_array['name'] ?></td> <td><?= $s_array['classyear'] ?></td> <td><?= $s_array['status'] ?></td> </tr> <? } /* end if ($x == TRUE) */ ?>
-- Ferdinand Beyer <fb@fbeyer.com>

Wez Furlong

22 years ago
php-general@lists.php.net On Tue, 13 Jul 2004 20:10:26 +0200, Ferdinand Beyer <fb@fbeyer.com> wrote:

Marc Richards

22 years ago
Wez Furlong wrote:
> php-general@lists.php.net >
True. Discussions about whether or not to use a templating system or using comments for readability is off topic. However I am trying to find out if there is a technical reason for not including the alternative syntax for this control structure or any other reason why it was left out. Marc