@unless - Conditional Rendering for False Values
The @unless directive in Ahmed PHP Template Engine is used to execute a block of code only if a given condition evaluates to false. It is the opposite of @if and provides a cleaner way to check for negated conditions.
Syntax
@unless(condition)
// Code to execute if condition is false
@endunlessconditionis the expression being evaluated.The enclosed block executes only if
conditionisfalse.
Example
@set(isAdmin, false)
@unless(isAdmin)
<p>You do not have admin privileges.</p>
@endunlessOutput
<p>You do not have admin privileges.</p>Notes
@unlessis a shorthand for@if(!condition) ... @endif.It makes templates more readable when checking for
falseconditions.Can be combined with
@elsefor alternative logic handling.
Last updated