Why does the str_contain function in my PHP 7.4 project work properly?
P粉217629009
P粉217629009 2024-01-29 11:03:27
0
1
401

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?

P粉217629009
P粉217629009

reply all(1)
P粉801904089

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!