Stable Release in branch 4.0
4.0.6
Released 23 Jun 2001
(25 years ago)
SoftwarePHP
Version4.0
Status
End of life
Initial release4.0.0
22 May 2000
(26 years ago)
Latest release4.0.6
23 Jun 2001
(25 years ago)
End of bug fixes23 Jun 2000
(Ended 26 years ago)
End of security fixes23 Jun 2001
(Ended 25 years ago)
Release noteshttps://www.php.net/ChangeLog-4.php#4.0.6
Source codehttps://github.com/php/php-src/tree/php-4.0.6
Documentationhttps://www.php.net/manual/en/
Downloadhttps://www.php.net/releases/4.0.6
PHP 4.0 ReleasesView full list

What Is New in PHP 4.0

Category Key Changes
Core Engine New Zend Engine, Reference Counting, Output Buffering
Web Features Sessions, Output Buffering, HTTP Session Management
Language Features Boolean Type, print() as construct, Expanded for loop
General Improvements Performance, COM Support, Build System (autoconf, libtool)

How did the core engine improve in PHP 4.0?

The biggest change was the new Zend Engine, which completely replaced the old PHP 3.0 engine. This new core introduced a much more efficient memory management system using reference counting. In practice, this meant scripts ran faster and used less memory, which was a massive win for building larger applications.

Output buffering was another game-changer. It allowed developers to capture output before sending it to the browser. This is essential for tasks like sending HTTP headers after some HTML has already been generated or for implementing custom output filters.

What new web features were introduced?

Built-in session support was a headline feature. Before PHP 4, you had to handle user sessions manually with cookies or hidden form fields. The new session functions made state management across page views trivial and secure.

The improved HTTP session management made it easier to handle cookies and headers. This provided a more robust foundation for building interactive web applications that needed to track users.

What language syntax was added?

PHP finally got a proper boolean type with the TRUE and FALSE constants. This cleaned up a lot of logic that previously relied on integers (1 and 0) for truthy and falsy values.

The print() language construct was added, giving developers another option for output besides echo. The for loop also became more powerful, supporting more complex iterative expressions.

Were there any other general improvements?

Performance was a major focus, and the Zend Engine delivered significant speed boosts across the board. The build system was modernized with autoconf and libtool, making it easier to compile PHP on various Unix-like systems.

Support for COM on Windows opened up new possibilities for scripting Microsoft Office applications and other Windows-specific components directly from PHP scripts.

FAQ

Was PHP 4.0 a major breaking change from PHP 3.0?
It was a major rewrite under the hood, but it maintained a high degree of backward compatibility. Most PHP 3 scripts continued to run without modification, which made adoption smooth for existing projects.

Why was the Zend Engine such a big deal?
It provided a modern foundation for the language with better memory management and performance. This directly enabled the development of more complex and resource-intensive applications that weren't practical before.

How did output buffering change development?
It solved the "headers already sent" error by letting you buffer all output. This allowed developers to set cookies or redirect pages at any point in the script, not just at the very beginning.

Did the new boolean type fix comparison issues?
It was a step in the right direction for type consistency. However, the loose type comparison system remained, so developers still had to be careful with comparisons between different data types.

What was the most impactful feature for web developers?
The built-in session management. It eliminated the need for custom session handling code and provided a standardized, secure way to maintain user state across multiple requests.

Releases In Branch 4.0

VersionRelease date
4.0.623 Jun 2001
(25 years ago)
4.0.530 Apr 2001
(25 years ago)
4.0.419 Dec 2000
(25 years ago)
4.0.311 Oct 2000
(25 years ago)
4.0.229 Aug 2000
(25 years ago)
4.0.128 Jun 2000
(26 years ago)
4.0.022 May 2000
(26 years ago)