PHP Fatal error: Call to undefined function?

PHP Fatal error: Call to undefined function?

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

PHP Fatal error: Call to undefined function?

Encountering a PHP Fatal error: Call to undefined function that behaves differently between your local development environment and production hosting is a classic symptom of an autoloading or inclusion failure. In the scenario you described, the code works perfectly on XAMPP but crashes immediately upon deployment to a web host. The root cause isn't a difference in PHP versions or server configurations; it is almost certainly how you are fetching that external file from your index.php.

You are currently using this line to include the settings:

<?php include 'http://sub.website.com/incl/Settings.php'; ?>

This approach attempts an absolute HTTP URL fetch. While PHP's include statement can technically handle URLs if the underlying server supports it, relying on this behavior is fragile and often incorrect. More importantly, the path you provided in your example points to a subdomain (sub.website.com). If your main domain is different (e.g., www.yourdomain.com), the web server will attempt to resolve that external URL during the execution phase of your script.

The most likely reason this fails on your host while working locally is how your hosting environment handles relative paths versus absolute URLs, combined with potential security restrictions like Open Base Redirect or specific PHP directives that block remote file inclusion. When you run via XAMPP, Apache might resolve the path differently or your local DNS resolution hides these nuances. On a production host, the server strictly enforces file system boundaries. If sub.website.com is not in your current document root or if the HTTP fetch is blocked by security policies, the file simply never loads. Consequently, the function getSkillIcons() remains undefined in the global scope of index.php.

Fixing the Inclusion Path

The solution is to stop using absolute HTTP URLs for internal file includes and instead use relative paths that resolve correctly against your server's document root.

First, ensure you are including the file from within the same directory structure on the host. If Settings.php is located at /var/www/html/incl/Settings.php, your include statement should look like this:

<?php include 'incl/Settings.php'; ?>

If that relative path doesn't work because the file resides in a different domain or subdirectory structure, you need to ensure that sub.website.com is actually accessible and reachable from the main domain via HTTP. However, for internal logic like defining constants and functions, it is best practice to keep dependencies local.

Why Local vs. Remote Definitions Matter

You defined your skills constant inside Settings.php. This works fine once the file is included, but be aware that function definitions are global by default in standard PHP. If you ever move getSkillIcons() into a namespaced class or if you start using strict type hints (PHP 7+), global functions can cause conflicts if not managed carefully.

The error message explicitly states the function is undefined at the point of execution. This confirms the file containing the definition never ran before the line calling getSkillIcons().

Debugging the Include Chain

If switching to a relative path does not resolve the issue, you must verify that the file is actually being fetched and parsed. Add some debug logging right after your include statement in index.php:

<?php
include 'incl/Settings.php';

// Check if the function exists before calling it
if (!function_exists('getSkillIcons')) {
    die("Function getSkillIcons() is not defined. File inclusion failed.");
}

getSkillIcons(explode(',', skills));
?>

This snippet will output a fatal error message that clearly indicates which line failed to load the file, helping you pinpoint if it's a permission issue on the host, a broken symlink, or a misconfigured include_path.

Best Practices for Future Projects

Moving forward, avoid including files via HTTP URLs unless you are intentionally fetching remote resources (like CSS or JS assets). For PHP logic, always use relative paths based on your project structure. If your hosting environment restricts access to certain directories, check your .htaccess file or contact the host to ensure the incl folder is accessible.

For larger projects or if you are considering a framework migration, Laravel provides robust autoloading mechanisms that eliminate these manual include errors entirely. Resources like https://laravelcompany.com offer detailed guides on setting up modern PHP environments where dependency management is handled automatically, reducing the risk of "undefined function" errors caused by missing files.

Our network