GuidesWhat's the Difference Between PHP3 and PHP4? Page 2

What’s the Difference Between PHP3 and PHP4? Page 2

ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

PHP4 is a complete rewrite of PHP3 at the heart of the language’s engine. But why did the authors decide to completely rewrite the language?

The manner in which PHP3’s scripting engine works is not adapted to the execution of rich, large-scale applications such as Phorum or KeyStone. Indeed, this engine reads PHP script instructions line-by-line and then executes them one-by-one, thus enabling PHP3 to obtain good performance with short and simple scripts. However, it yields rather mediocre performance with larger applications, and users must understand that PHP3 was not designed to execute such applications.

Thus, PHP3’s two creators decided to implement a scripting engine capable of reading all PHP code and “compiling” it before executing it. And Zend was born. This was not an easy task. Although incompatibilities could be conceived at the time of migration from PHP2 to PHP3, such differences had to be limited as much as possible between PHP3 and PHP4 due to the installed base and the number of PHP3 scripts already in use. We can congratulate PHP4’s authors on a job well done because the incompatibilities that do exist are only minor.

Although Zend is an integral part of PHP4, it is actually a scripting/runtime engine independent of the PHP language. On this account, it is possible to use Zend in MySQL as the basis for the development of a stored procedure language specific to this database system.

Without going into the details of internal implementation, we can point out a few things about the Zend/PHP4 combination.

PHP4’s new architecture enabled its authors to add an abstraction layer in relation to the Web server at the heart of its language. Until now, with PHP3 users had the choice of using it as a specific module for the Apache server or in CGI mode for all other HTTP servers. With PHP4 it is now possible to imagine better integration with Web servers other than Apache. This is in fact the case for Microsoft’s HTTP server, IIS. PHP4 now works as an ISAPI filter for Microsoft’s IIS server. For this reason, different parts of PHP4 code had to be made compliant with use in a multithread environment (PHP4 is “thread-safe”).

Many new features concern PHP4’s internal implementation; however, they don’t really concern PHP programmers directly. Nonetheless, it is worth noting two important points: memory allocation and reference counting mechanisms. In other words, those mechanisms that free up resources that were no longer used were completely rethought. Performance and memory use are thus improved, especially for objects and tables. The more data the variables contain, the more memory saved.

Get the Free Newsletter!

Subscribe to Daily Tech Insider for top news, trends & analysis

Latest Posts

Related Stories