PHP Fatal error: Uncaught Error: Call to undefined function
PHP Fatal error: Uncaught Error: Call to undefined function
DodaTech
2 min read
The “Call to undefined function” fatal error stops script execution when PHP cannot find a function you are trying to invoke. This is one of the most common PHP errors for beginners and experienced developers alike.
What It Means
PHP has a function registry — every built-in and user-defined function must be available at the time of the call. When you call a function that PHP has never seen before, it throws a fatal error. Unlike a warning, this stops your script immediately.
Why It Happens
- Typo in the function name — you wrote
stripos()instead ofstrpos(). - Function not defined yet — the function definition comes after the call.
- File not included — the file containing the function was never
required orincluded. - Missing PHP extension — functions like
mysqli_connect()require themysqliextension. - Wrong namespace — calling a function in a namespace without importing it or using the full path.
- PHP version mismatch — the function was added in a newer version (e.g.,
str_contains()needs PHP 8.0+).
How to Fix It
1. Check for typos
Compare the function call to its definition:
// Typo — "conver" instead of "convert"
$result = converToUpper('hello'); // ❌
// Correct
$result = convertToUpper('hello'); // ✅
2. Include the required file
// Make sure the file defining the function is included
require_once 'helpers.php';
// Now the function is available
echo sanitize_input($_POST['email']);3. Use the full namespace path
If you are working in a namespace, prefix the call with a backslash to fall back to the global namespace:
namespace App\Services;
// This looks in App\Services namespace
$result = strpos($haystack, $needle); // ❌
// This uses the global strpos
$result = \strpos($haystack, $needle); // ✅
4. Enable the required PHP extension
# Find which extension provides the function
php -m | grep -i mysqli
# Install it (Ubuntu/Debian)
sudo apt install php-mysql5. Check your PHP version
// str_contains needs PHP 8.0+
if (PHP_VERSION_ID >= 80000) {
echo str_contains('hello', 'ell'); // ✅
} else {
echo (strpos('hello', 'ell') !== false); // ✅ fallback
}Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro