function twig_test_empty

Checks if a variable is empty.

<pre> {# evaluates to true if the foo variable is null, false, or the empty string #} {% if foo is empty %} {# ... #} {% endif %} </pre>

Parameters

mixed $value A variable:

Return value

Boolean true if the value is empty, false otherwise

1 call to twig_test_empty()
_twig_default_filter in drupal/core/vendor/twig/twig/lib/Twig/Extension/Core.php
1 string reference to 'twig_test_empty'
Twig_Extension_Core::getTests in drupal/core/vendor/twig/twig/lib/Twig/Extension/Core.php
Returns a list of tests to add to the existing list.

File

drupal/core/vendor/twig/twig/lib/Twig/Extension/Core.php, line 1013

Code

function twig_test_empty($value) {
  if ($value instanceof Countable) {
    return 0 == count($value);
  }
  return false === $value || empty($value) && '0' != $value;
}