As the title suggests, I'm developing a Symfony project using PHP 7.4, and I've been using the PHP function str_contains
for a while now. However, while looking up some stuff today, I discovered that this function was introduced in PHP 8.0, as explained here: https://php.watch/versions/8.0/str_contains
In my project, str_contains
works fine, so my question (which may sound weird) is: why does my code work? Shouldn't it crash when I try to use the function?
As suggested by @deceze and @u_mulder in the comments, it works thanks to the Symfony polyfill, which converts many functions, especially
str_contains
, from Backtracking in newer versions.