How To

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

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!

Click to rate this post!
[Total: 4 Average: 4]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

Recent Posts

Five Essential Payroll Compliance Tips for eCommerce Startups

Are you setting up a payroll system for your eCommerce startup? Ensuring compliance with myriad…

3 hours ago

Optimizing Laravel Blade: Unlocking Advanced Fetcher Techniques

In the expansive universe of Laravel development, Blade serves as the stellar templating engine, propelling…

4 hours ago

Magento 2: Add Quantity Increment and Decrement on Category Page

Hello Magento Friends, In this blog, we will discuss about adding quantity increment and decrement…

2 days ago

How to Integrate ChatGPT with Laravel Application?

In this guide, we'll explore how to integrate ChatGPT, an AI-powered chatbot, with a Laravel…

5 days ago

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

1 week ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

1 week ago