php.net |  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
Votes:6
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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 http://php.benscom.com/manual/en/control-structures.alternative-syntax.php)  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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-09-22 09:26 UTC] nikic@php.net
Closing as duplicate of https://bugs.php.net/bug.php?id=26411. (This bug is older, but the other one has more discussion.)
 [2012-09-22 09:26 UTC] nikic@php.net
-Status: Open +Status: Duplicate -Package: Feature/Change Request +Package: *General Issues
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 17:01:29 2024 UTC