I have a problem baffling me terribly. I noticed this before but didn\'t give it any heed until today.
I was trying to write my own check for integer strings. I know of
Note: This answer is in response to a related question about the Twig template engine, that was marked as a duplicate, and redirects here.
Because the context is different, this answer is provided to those members of the SO community who may benefit from additional details specifically related to twig exclusively.
TL;DR: see this post How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?
==
) produce unexpected results in Twig?Why do the following produce different results?
{{ dump(0 == 'somekey') }} ==> true {{ dump(0|lower == 'somekey') }} ==> false
===
in Twig is much less likely to produce unexpected results.===
in the same way as standard PHP===
using same as