|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #21555 Possible extensions to alternative control syntax
Submitted: 2003-01-09 15:48 UTC Modified: 2012-09-22 09:26 UTC
Avg. Score:4.0 ± 0.8
Reproduced:6 of 6 (100.0%)
Same Version:3 (50.0%)
Same OS:4 (66.7%)
From: gabe at bravenet dot com Assigned:
Status: Duplicate Package: *General Issues
PHP Version: 4.3.0 OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: gabe at bravenet dot com
New email:
PHP Version: OS:


 [2003-01-09 15:48 UTC] gabe at bravenet dot com
The alternative control structure syntax (see  is very useful for templating purposes. However, I miss the smarty-style 'else' clauses: foreachelse, whileelse etc.

I would like to be able to do this:

<?php foreach($array as $item): ?>
// if array has items, this is repeated once per item

<?php foreachelse: ?>
// we get here if $array has no items, then exit

<?php endforeach; >

...or this...

<?php while($something == $somestate): ?>
// repeated while condition is met

<?php whileelse: ?>
// if condition is never met we go here once and exit.

<?php endwhile; ?>

I think these additions would be fairly useful.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-09-22 09:26 UTC]
Closing as duplicate of (This bug is older, but the other one has more discussion.)
 [2012-09-22 09:26 UTC]
-Status: Open +Status: Duplicate -Package: Feature/Change Request +Package: *General Issues
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Oct 06 15:05:53 2022 UTC