Solved: PHP Fatal Error “Call to Undefined Function str_contains()” After Upgrading to Magento 2.4.x

PHP Fatal Error Call to Undefined Function strcontains After Upgrading to Magento 24x Solved

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!

Previous Article

Magento 2: Allow Guests to Write Reviews

Next Article

[Error Solved] Magento 2: Failed to open stream: No such file or directory in composer autoload_real.php

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *

Get Connect With Us

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨