@isset - Checking If a Variable Is Set
The @isset directive in Ahmed PHP Template Engine is used to check whether a variable has been defined and is not null. It allows conditional rendering based on the presence of a variable.
Syntax
@isset(variable)
// Code to execute if variable is set
@endissetvariableis the variable being checked.The enclosed block of code executes only if the variable exists and is not
null.
Example
@set(name, 'Ammar')
@isset(name)
<p>Hello, {{ name }}!</p>
@endissetOutput
<p>Hello, Ammar!</p>Notes
@issetis useful for ensuring variables exist before displaying them.If the variable is not set, the enclosed block is skipped.
Can be combined with
@elseor@emptyfor alternative behavior.
Last updated