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

PHP 4 — Zend Engine 1, Classes Without OOP

PHP PHP 4.0+ Beginner
debt(d3/e3/b3/t7)
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 list rector and phpcs, both of which can flag PHP 4 patterns like the `var` keyword via code patterns (\bvar \$). These are standard tools commonly run in CI pipelines, placing detection squarely at the linter/default-tool level rather than requiring specialist analysis or manual review.

e3 Effort Remediation debt — work required to fix once spotted

Closest to 'simple parameterised fix' (e3). The quick_fix summary describes replacing `var` with visibility modifiers, adding type hints, and removing pass-by-reference object hacks — a pattern-level replacement within a file or small component. It is more than a single-line patch but does not span architectural concerns, aligning with e3.

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

Closest to 'localised tax' (b3). The applies_to scope is PHP 4.0–4.4 web contexts only, meaning this is legacy code that, if present, is contained to a specific (and obsolete) codebase segment. Modern codebases won't carry this weight at all; it only burdens teams maintaining very old PHP code, making it a localised rather than system-wide tax.

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

Closest to 'serious trap' (t7). The misconception field explicitly states that PHP 4 objects were passed by value (copied), not by reference — directly contradicting how modern PHP 5+ OOP works and how developers from other OO languages (Java, Python, Ruby) expect objects to behave. This is a behavioral contradiction versus a similar concept in the same language's later version, making it a serious trap that can cause subtle, hard-to-diagnose bugs in any code ported from PHP 4.

About DEBT scoring →

TL;DR

PHP 4 (2000) introduced the Zend Engine 1.0 — dramatically improving performance and adding basic classes, though objects were passed by value and OOP was rudimentary.

Explanation

PHP 4 (May 2000) introduced: Zend Engine 1.0 (rewrote by Suraski and Gutmans), sessions, output buffering, basic class syntax (class Foo { var $x; function bar() {} }). Critical limitation: objects were copied by value on assignment, not by reference — $b = $a cloned the object. This made OOP impractical at scale. PHP 4 reached End of Life in 2007. The era defined PHP as a web scripting language: register_globals on by default, magic_quotes active, mysql_ functions prevalent. Many legacy codebases still carry PHP 4 patterns.

Common Misconception

PHP 4 classes worked like modern OOP — objects were passed by value (copied), not by reference. $obj2 = $obj1 created a full copy.

Why It Matters

PHP 4's limitations drove the complete OOP redesign in PHP 5 — understanding the history explains why PHP 5 was such a dramatic improvement.

Common Mistakes

  • Using PHP 4 class patterns (var keyword, no visibility, no type hints) in modern code.
  • Forgetting PHP 4 had no try/catch — error handling was purely procedural.

Code Examples

✗ Vulnerable
<?php
class User {
    var $name; // PHP 4 style
    function getName() {
        return $this->name;
    }
}
✓ Fixed
<?php
class User {
    public function __construct(
        private readonly string $name
    ) {}

    public function getName(): string {
        return $this->name;
    }
}

Added 23 Mar 2026
Views 121
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings S 1 ping M 0 pings T 0 pings W 0 pings T 3 pings F 1 ping S 2 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 1 ping F 0 pings S 0 pings S 1 ping M 1 ping T 0 pings W 0 pings T 3 pings F 2 pings S 0 pings S 0 pings M
No pings yet today
No pings yesterday
Scrapy 15 Amazonbot 12 SEMrush 10 PetalBot 10 ChatGPT 7 Perplexity 7 Ahrefs 7 Unknown AI 6 Google 6 Meta AI 2 Twitter/X 2 Bing 2 Applebot 2 Qwen 1
crawler 84 crawler_json 2 your_contextpost 1 pre-tracking 2
🧱 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
🔵 Info ⚙ Fix effort: Medium
⚡ Quick Fix
Replace var keyword with public/protected/private. Add type hints. Remove pass-by-reference hacks for objects (unnecessary in PHP 5+).
📦 Applies To
PHP 4.0+ web
🔗 Prerequisites
🔍 Detection Hints
\bvar \$
Auto-detectable: ✓ Yes rector phpcs
🤖 AI Agent
Confidence: High False Positives: Low ✓ Auto-fixable Fix: Low Context: Class


✓ schema.org compliant