Edit on GitHub
Jump to docs navigation

Twig Components / Methods / int

int is a Twig test to ...

int is a Twig test to test a value for being an int (like is_int in PHP).

It uses the mentioned PHP functions / comparisons internally, so you have the same behavior as in PHP.

{% if somevar is integer %} {# no equivalent in Twig %} #}
{% endif %}
{% if somevar is int %} {# same as integer test above, alternate way to write it %} #}
{% endif %}

Source: Squirrelphp



Edit this page on GitHub
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.