---
title: "Solved: PHP Fatal Error “Call to Undefined Function str_contains()” After Upgrading to Magento 2.4.x"
url: "https://magecomp.com/blog/solved-php-fatal-error-after-upgrading-to-magento-2-4-x/"
date: "2022-03-11T14:57:09+00:00"
modified: "2022-03-11T14:57:09+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 268
reading_time: "2 min read"
summary: "Hello Magento Friends,"
description: "Resolve PHP fatal error Call to Undefined Function str_contains() after upgrading to Magento 2.4.x with composer require command"
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "A Comprehensive Guide on Abandoned Cart Email for Magento 2"
    url: "https://magecomp.com/blog/comprehensive-guide-on-magento-2-abandoned-cart-email/"
  - title: "How to Get Wishlist Data Using Customer ID in Magento 2"
    url: "https://magecomp.com/blog/get-wishlist-data-using-customer-id-magento-2/"
  - title: "How to Change My Account Navigation Links Title Dynamically in Magento 2?"
    url: "https://magecomp.com/blog/change-account-navigation-links-title-dynamically-magento-2/"
---

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

_Published: March 11, 2022_  
_Author: Dhiren Vasoya_  

![PHP Fatal Error Call to Undefined Function strcontains After Upgrading to Magento 24x Solved](https://magecomp.com/blog/wp-content/uploads/2022/03/PHP-Fatal-Error-Call-to-Undefined-Function-strcontains-After-Upgrading-to-Magento-24x-Solved-1024x512.webp)

**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**](https://magecomp.com/magento-upgrade-service.html).
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**](https://magecomp.com/blog/solved-magento-2-currency-symbol-not-showing/) or [**Unable to Serialize Value**](https://magecomp.com/blog/solved-unable-to-serialize-value-in-magento-2/) 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!**


---

_View the original post at: [https://magecomp.com/blog/solved-php-fatal-error-after-upgrading-to-magento-2-4-x/](https://magecomp.com/blog/solved-php-fatal-error-after-upgrading-to-magento-2-4-x/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-08-26 08:46:32 UTC_  
