PAD - PHP Application Driver


home | manual | reference | regression | sequence | develop | apps


Else

When the result of a PAD tag is false the part after @else@ is used.

HTML RESULT
{if 2 > 1}
true
@else@
false
{/if}
true
{if 1 > 2}
true
@else@
false
{/if}
false


The @else@ construct is a general feature of every PAD tag, it applies to all PAD tags.

PHP
constructs/else_4.php
HTML
constructs/else_4.pad
Result
<?php

$myVar
= FALSE;

?>
{myVar}
true
@else@
false
{/myVar}
false

When the result of a PAD tag is an empty array the part after @else@ is used.

HTML RESULT
{data 'myArray1'}
[1,2,3]
{/data}
{myArray1}
Occurence {$myArray1} <br>
@else@
No occurences
{/myArray1}
Occurence 1
Occurence 2
Occurence 3
{data 'myArray2'}
[]
{/data}
{myArray2}
Occurence {$myArray2} <br>
@else@
Nothing to see here
{/myArray2}
Nothing to see here


The @else@ context can also be given with the 'else' option at the tag itself.

HTML RESULT
{data 'myArray'}
[]
{/data}
{content 'nothing'}
Nothing to see here
{/content}
{myArray else='nothing'}
Occurence {$myArray} <br>
{/myArray}
Nothing to see here
{if 1 > 2, else='nothing'}
true
{/if}
Nothing to see here


Basic Concepts

  

Advanced concepts

  

Constructs

Miscellaneous




home | manual | reference | regression | sequence | develop | apps

(c) 2003-2025 Herbert Groot Jebbink