Fatal error: Call to undefined function iconv_substr() in /home/foodpack/public_html/app/code/core/Mage/Core/Helper/String.php on line 103

Fatal error: Call to undefined function iconv_substr() in /home/foodpack/public_html/app/code/core/Mage/Core/Helper/String.php on line 103

August 2, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Fatal error: Call to undefined function iconv_substr() in /home/foodpack/public_html/app/code/core/Mage/Core/Helper/String.php on line 103

Solving the “Call to undefined function iconv_substr()” Error

The error message you’re encountering is common among certain Magento installations running on PHP 7 or later versions:

Fatal error: Call to undefined function iconv_substr() in /home/foodpack/public_html/app/code/core/Mage/Core/Helper/String.php on line 103

Let’s delve into the root cause and find a solution.

Understanding the Error

The iconv_substr() function is specific to PHP versions prior to 7. This function was deprecated in PHP 5.6 and completely removed in PHP 7, leading to this error when Magento attempts to use it.

Why Does This Error Occur?

This issue arises because the core Magento files are still referencing the iconv_substr() function, which is no longer supported in your current PHP version (likely PHP 7 or later).

Solving the Problem

Step 1: Identify Your PHP Version

First, confirm that you’re indeed running a PHP version 7 or later. You can do this by adding the following line to a PHP file and checking its output:

<?php echo phpversion(); ?>

If your output is anything from 7.0 upwards (e.g., 7.3.28), proceed with the next steps.

Step 2: Update Your PHP Code

To resolve this issue, you need to replace every occurrence of iconv_substr() in your Magento core files with the native PHP function substr(). This function serves the same purpose but is supported in all modern PHP versions.

Here’s how you can do it:

  1. Open the file /home/foodpack/public_html/app/code/core/Mage/Core/Helper/String.php.

  2. Locate line 103, which should contain this line:

    return iconv_substr($string, $offset, $length, self::ICONV_CHARSET);
    
  3. Replace it with the native PHP function:

    return substr($string, $offset, $length);
    
  4. Save your changes and exit.

Best Practices to Avoid Such Issues

To prevent similar problems in the future, consider these best practices:

  1. Regular Magento Updates: Always keep your Magento version up-to-date with the latest security patches and feature updates provided by Adobe. Updating ensures you have the most recent, optimized codebase.

  2. PHP Version Compatibility: Before upgrading PHP or migrating to a new server, always check if your Magento installation is compatible with the specific PHP version on that server. You can use tools like LaravelCompany’s Magento Compatibility Checker for quick verification.

  3. Development and Staging Environments: Always test changes in a development environment before deploying them to your live server. This allows you to catch compatibility issues early and avoid downtime on your production site.

Conclusion

The “Call to undefined function iconv_substr()” error is a common issue that can be quickly resolved by updating the core Magento files to use the native PHP substr() function instead of the deprecated iconv_substr().

Remember, while this fix addresses the immediate problem, it’s important to follow best practices like regular updates and testing in development environments to ensure long-term stability and security.

If you found this guide helpful, consider sharing it with your network or reaching out if you need further assistance. At LaravelCompany, we specialize in providing expert Magento solutions tailored to your business needs.

Errors

Our network