Does Twig have a null coalesce operator?

The null-coalescing operator was formally introduced in Twig 1.24 (Jan. 25, 2016).

* adding support for the ?? operator

Which means it’s now possible to do this…

{{ title ?? "Default Title" }}

You can even chain them together, to check multiple variables until a valid non-null value is found.

{{ var1 ?? var2 ?? var3 ?? var4 }}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)