Hello Magento Friends,
I am back with another solution for the errors you might face while working with Magento 2. Today I am going to explain How to Fix PHP Fatal Error “Call to Undefined Function str_contains()” After Upgrading to Magento 2.4.x.
Upgrading is essential to enhance store performance and security. Smoothly upgrade to the newest Magento version.
When Magento merchants try to upgrade to Magento 2.4.x, they may come across the below error
“Call to undefined function Magento\Framework\Filesystem\Directory\str_contains() in <…>/magento/vendor/magento/framework/Filesystem/Directory/DenyListPathValidator.php:74”
This error is caused because the str_contains() function is supported by PHP 8 and Magento version 2.4.3 and 2.3.7-p1 are compatible with PHP 7.4. However, this issue will be fixed in upcoming releases, Magento 2.4.4, 2.4.3-p1, and 2.3.7-p2.
As for now, let us find a way to solve the error
How to Fix PHP Fatal Error Call to Undefined Function str_contains() After Upgrading to Magento 2.4.x?
Step 1: Open the terminal and run the below command from the Magento root folder.
composer require symfony/polyfill-php80
Step 2: Then, run the Magento setup upgrade command to verify whether an issue is fixed or not
php bin/magento setup:upgrade
Conclusion:
By doing so you can eliminate PHP Fatal error after upgrading the Magento 2 version. I have also provided the solution for Currency Symbol Not Showing or Unable to Serialize Value errors while upgrading the Magento 2 version.
Were you able to solve the error with the above solution? If yes, share it with your friends. If not, contact us to get the ideal solution for your error.
Happy Coding!