Call to Undefined Function/Method
TL;DR
'Call to undefined function' means the function wasn't declared, the file wasn't loaded, or the PHP extension providing it isn't installed.
Explanation
This fatal error happens when: (1) calling a function that doesn't exist — typo or not yet defined, (2) calling a function from a file not yet loaded — use require/autoload, (3) calling a function from a PHP extension not installed/enabled (e.g. imagecreatetruecolor without ext-gd), (4) calling a method on a wrong type (calling string methods on null — PHP 8 throws TypeError). Extension functions: use extension_loaded('gd') to check. Static method errors: 'Call to undefined method' — check class name, method visibility, and namespace.
Common Misconception
✗ Call to undefined function always means a typo — it often means a PHP extension isn't enabled or a file wasn't included.
Why It Matters
Extension-based errors are environment-specific and often only appear in production where PHP extensions differ from development.
Common Mistakes
- Not declaring extension dependencies in composer.json require section.
- Calling instance methods statically or vice versa.
- Using functions from optional extensions without checking extension_loaded().
Code Examples
✗ Vulnerable
// ext-gd not installed in production
$img = imagecreatetruecolor(800, 600);
// Fatal: Call to undefined function imagecreatetruecolor()
✓ Fixed
// In composer.json:
// "require": {"ext-gd": "*"}
// Runtime check:
if (!extension_loaded('gd')) {
throw new \RuntimeException('GD extension required. Install php-gd.');
}
$img = imagecreatetruecolor(800, 600);
Tags
🤝 Adopt this term
£79/year · your link shown here
Added
22 Mar 2026
Views
22
🤖 AI Guestbook educational data only
|
|
Last 30 days
Agents 0
No pings yet today
Amazonbot 7
Unknown AI 3
Google 3
Perplexity 3
ChatGPT 1
Meta AI 1
Also referenced
How they use it
crawler 16
crawler_json 1
pre-tracking 1
Related categories
⚡
DEV INTEL
Tools & Severity
🟠 High
⚙ Fix effort: Low
⚡ Quick Fix
Declare required extensions in composer.json (ext-gd, ext-intl etc). Use extension_loaded() guards. Check with php -m for installed extensions.
📦 Applies To
PHP 4.0+
web
cli
🔗 Prerequisites
🔍 Detection Hints
imagecreate|iconv|intl_|curl_
Auto-detectable:
✓ Yes
phpstan
composer
⚠ Related Problems
🤖 AI Agent
Confidence: High
False Positives: Low
✗ Manual fix
Fix: Low
Context: File