@empty - Checking If a Variable Is Empty
The @empty
directive in Ahmed PHP Template Engine is used to check whether a variable is empty (i.e., it is not set, null
, false
, or an empty string/array). This helps in conditionally displaying content based on the absence of a value.
Syntax
variable
is the variable being checked.The enclosed block of code executes only if the variable is empty.
Example
Output
Notes
@empty
is useful for handling cases where a variable may be unset or contain an empty value.If the variable has a value, the enclosed block is skipped.
Can be combined with
@isset
for advanced conditional checks.
Last updated