← Home ← Codex ← DEBT ← Engine
Browse by Category
+ added · updated 7d
← Back to glossary

Deprecated & Removed PHP Functions

PHP PHP 5.0+ Beginner
debt(d3/e3/b5/t5)
d3 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'default linter catches the common case' (d3). The term's detection_hints lists rector, phpstan, and php-deprecation-detector as tools that can catch deprecated function usage with automated=yes. These are standard tooling in modern PHP projects and catch deprecations reliably. Slightly better than d5 because PHPStan is increasingly default in PHP CI pipelines, though not as instant as a syntax error.

e3 Effort Remediation debt — work required to fix once spotted

Closest to 'simple parameterised fix' (e3). The quick_fix states 'run rector/rector with PHP_80 PHP_83 sets to auto-migrate deprecated patterns' — rector can automatically transform most deprecated patterns to their modern equivalents. While some deprecated functions require manual thought (e.g., replacing mysql_* with PDO), most are straightforward replacements handled by automated tooling within a single component.

b5 Burden Structural debt — long-term weight of choosing wrong

Closest to 'persistent productivity tax' (b5). Deprecated functions apply across all PHP contexts (web, cli, queue-worker per applies_to), creating ongoing maintenance weight. Legacy codebases with mysql_*, each(), or magic_quotes references require consistent attention during PHP upgrades. The burden isn't architectural (b7-b9) since replacements exist, but it's more than localised (b3) because deprecations accumulate across the entire codebase and block major version upgrades.

t5 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'notable trap' (t5). The misconception field explicitly states: 'Deprecated means removed' — developers incorrectly believe deprecated functions no longer work, when in fact they still execute but emit E_DEPRECATED notices. Combined with common_mistakes noting that default PHP config hides these notices, developers don't realize their code is accumulating upgrade debt until they attempt a PHP version bump and face breaking changes.

About DEBT scoring →

Also Known As

PHP deprecated removed PHP functions legacy PHP functions

TL;DR

Functions removed or deprecated in modern PHP versions — using them triggers errors or silent failures in new runtimes.

Explanation

PHP evolves quickly; common removed functions include mysql_* (removed in PHP 7.0 — use PDO or mysqli), ereg_* (removed PHP 7.0 — use preg_*), create_function (removed PHP 8.0 — use closures), each() (removed PHP 8.0), and magic_quotes_* (removed PHP 7.4). Deprecated functions generate E_DEPRECATED warnings and will be removed in a future version. Regular audits with php -l, PHPStan, or PHP_CodeSniffer help identify usage. Static analysis tools can be configured to flag calls to known deprecated functions.

Common Misconception

Deprecated means removed. Deprecated functions still work but emit E_DEPRECATED notices — they signal upcoming removal in a future major version. Treating deprecation warnings as errors in CI (error_reporting with E_DEPRECATED) catches these before they become breaking changes.

Why It Matters

Deprecated functions are removed in future PHP versions — code depending on them breaks silently on upgrade, and they often have security or performance issues that motivated their deprecation.

Common Mistakes

  • Not running PHP with E_DEPRECATED enabled — deprecated calls produce no visible errors in default config.
  • Using each(), reset(), current() in loops — deprecated in PHP 7.2 and removed later.
  • Relying on magic_quotes, register_globals, or mysql_* functions in legacy codebases without an upgrade plan.
  • Not checking the PHP migration guides before upgrading — each major version deprecates a significant list.

Code Examples

✗ Vulnerable
// Deprecated mysql_* functions — removed in PHP 7:
$conn = mysql_connect('localhost', 'user', 'pass');
$result = mysql_query('SELECT * FROM users', $conn);
while ($row = mysql_fetch_assoc($result)) { /* ... */ }
// Use mysqli or PDO instead
✓ Fixed
// PHP 7.x removals:
// mysql_*()         → PDO or mysqli
// ereg()            → preg_match()
// split()           → explode() or preg_split()

// PHP 8.0 removals:
// each()            → foreach / array_key_first()
// create_function() → anonymous function

// PHP 8.1 deprecations:
// Passing null to non-nullable params

// PHP 8.2 deprecations:
// Dynamic properties (use #[AllowDynamicProperties] or declare explicitly)

// PHP 8.4 deprecations:
// Implicitly nullable params: fn(string $s = null) → fn(string|null $s = null)

// Detect deprecations in CI:
error_reporting(E_ALL); // catches E_DEPRECATED

// PHPStan deprecation rules:
$ composer require --dev phpstan/phpstan-deprecation-rules

Added 15 Mar 2026
Edited 22 Mar 2026
Views 97
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings F 1 ping S 1 ping S 0 pings M 0 pings T 1 ping W 1 ping T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 1 ping M 0 pings T 2 pings W 0 pings T 0 pings F 0 pings S
No pings yet today
No pings yesterday
Amazonbot 11 Ahrefs 8 ChatGPT 7 Scrapy 7 PetalBot 6 Perplexity 4 Brave Search 4 Unknown AI 3 SEMrush 3 Google 2 Applebot 2 Majestic 1 Meta AI 1 Twitter/X 1 Bing 1
crawler 57 crawler_json 3 pre-tracking 1
🧱 FUNDAMENTALS — new to this? Start with the ground floor.
PHP php A server-side scripting language that generates web pages and APIs — the code runs on the server, and only its output (usually HTML or JSON) reaches the browser.

PHP is often the first server-side language people meet, and understanding its execution model — script starts fresh on every request, no memory between requests — explains most of how the web backend works: sessions, databases, and caching all exist to bridge that per-request amnesia.

💡 Start with PHP 8.x, declare(strict_types=1), and PDO — skip any tutorial that mentions mysql_query().

Ask Codex about PHP →
DEV INTEL Tools & Severity
🟡 Medium ⚙ Fix effort: Medium
⚡ Quick Fix
Enable E_DEPRECATED in error reporting; run rector/rector with PHP_80 PHP_83 sets to auto-migrate deprecated patterns; fix before upgrading PHP version
📦 Applies To
PHP 5.0+ web cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
Functions removed in PHP 8: each() ereg() mysql_*() split() mcrypt_*(); create_function(); ${var} string interpolation style
Auto-detectable: ✓ Yes rector phpstan php-deprecation-detector
⚠ Related Problems
🤖 AI Agent
Confidence: High False Positives: Low ✓ Auto-fixable Fix: Low Context: Line


✓ schema.org compliant