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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Pull Requests

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: Sun Dec 22 06:01:30 2024 UTC