Zen: control structures

Back to Zen homepage

prev next

1. PHP inherited

There are available all PHP control structures, just with replaced angle brackets for curly brackets to make the code more readable stuffed into HTML. As a syntactic sugar it is possible to use slash instead of ending control tags, i.e.

{while($cond):} do something {endwhile} Equals to {while($cond):} do something {/while}

2. Loop

Loop introduces state object in iteration. In PHP, only value of iterable can be read in while, only key in for, and key and value in foreach syntax. Loop state object contains following properties:
{$langs = ["CZ" => "Czech", "EN" => "English", "RU" => "Russian", "CN" => "Chinese"]} {loop($langs as $L):} <div>{=$L->order."/".$L->length}: {="$L ($L->key)"}</div> {/loop}


1/4: Czech (CZ)
2/4: English (EN)
3/4: Russian (RU)
4/4: Chinese (CN)