Skip to main content
5 of 6
Removed misinformation about "is null" not being a test. Reorganized answer to more accurately address the question.
Lindsey D
  • 24.1k
  • 5
  • 54
  • 111

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 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.

Lindsey D
  • 24.1k
  • 5
  • 54
  • 111