is defined
- The variable has been defined, and set to any value (or null
).
is not null
- The variable has been defined, and is specifically not null
.
In PHP terms, it's like the difference between is_null()
vs. checking whether the variable exists using get_defined_vars()
(see this Stack Overflow threadStack Overflow thread for a little more clarity)
Try this experiment... Without setting myVar
, put this in your template:
{{ (myVar is defined) }}
Since that equates to false
, nothing will appear in your template. Now change it to this:
{{ (myVar is not null) }}
That will actually throw an error, since myVar
was never defined.