# alternative syntax for do...while

- Thread: https://externals.io/message/11143
- Original archive: https://news-web.php.net/php.internals/11143
- Started by Marc Richards on 2004-07-13T01:53:51+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #11143 — Marc Richards — 2004-07-13T01:53:51+00:00

URL: https://externals.io/message/11143#11143

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

---

## #11153 — Thomas Seifert — 2004-07-13T07:52:57+00:00

URL: https://externals.io/message/11143#11153 · In reply to: #11143

> <? 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

---

## #11167 — Red Wingate — 2004-07-13T12:37:48+00:00

URL: https://externals.io/message/11143#11167 · In reply to: #11143

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 ?

---

## #11175 — Marc Richards — 2004-07-13T15:30:22+00:00

URL: https://externals.io/message/11143#11175 · In reply to: #11153

Thomas Seifert wrote:

> 
> 
> 
> > […]
> 
> 
> 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

---

## #11177 — Marc Richards — 2004-07-13T15:34:33+00:00

URL: https://externals.io/message/11143#11177 · In reply to: #11167

Red Wingate wrote:

> Marc Richards wrote:
> 
> 
> > […]
> 
> 
> <?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
