Evolution of PHP as a language from version 1 to 8

Find out how the PHP programming language has evolved

Diego Delgado García

PHP, known as the Hypertext Preprocessor, is a server-side scripting language. It is mainly used for web development and was first released in 1995 by Rasmus Lerdorf. Since then, PHP has seen a large number of versions, each with significant improvements and changes. Let's take a look at the evolution of PHP from its inception to PHP 8, the last known version as of September 2021.

PHP versions and major changes

PHP/FI (Personal Home Page / Forms Interpreter) 1.0 (Released in 1995)

The first version of PHP, then known as PHP/FI, was developed by Rasmus Lerdorf. At the time, PHP was a simple set of CGI Perl scripts that helped Lerdorf maintain his personal resume and collect certain data. It wasn't until Lerdorf combined these scripts with C to form PHP/FI that PHP became a product that could be used by others.

PHP/FI 2.0 (Released in 1997)

PHP/FI version 2 introduced a number of features that laid the foundation for what PHP would become in the future. These features included support for forms and cookies, as well as the ability to embed PHP code directly into HTML.

PHP 3 (Released in the year 1998)

Developed by Andi Gutmans and Zeev Suraski, PHP 3 featured a complete overhaul of the language, establishing most of the syntax conventions we know today. It included support for objects for the first time, and it was the first version that really looked like a complete programming language.

PHP 4 (Released in the year 2000)

PHP version 4 introduced the Zend engine, a piece of software that interprets PHP code. This led to improved performance, as well as better support for object-oriented programming. It also included features such as session persistence and output buffering.

PHP5

PHP 5 introduced significant improvements to object-oriented programming, with the addition of abstract classes, interfaces, object cloning, and exceptions. Also, support for XML was improved and support for SQLite was introduced.

PHP 5.0 (Released in July 2004)

  • Object-oriented programming improvements : Introduced a complete object model including access modifiers, interfaces, cloning, and exceptions.
  • Improved XML handling : Added the SimpleXML extension for easier handling of XML.
  • SQLite: SQLite, a lightweight SQL database engine, was included in PHP by default.

PHP 5.1 (Released in November 2005)

  • PDO (PHP Data Objects) support: Provides an interface to access databases in PHP.
  • Performance improvements : Includes the addition of a garbage collector to kill reference cycles.

PHP 5.2 (Released in November 2006)

  • Introduction of filter_list() : Helps to validate and filter data in a safe way.
  • Performance and stability improvements : Includes the update to the PCRE library, which has improved compatibility and performance.

PHP 5.3 (Released June 2009)

  • Namespaces : They allow to better organize the code in packages.
  • Late Static Bindings : Improves code inheritance in PHP.
  • Closures (anonymous functions) : Functions can now be created without a specific name.
  • Exception handling improvements : The possibility of using multiple catch exceptions is introduced.
  • Support for nested ternary syntax without the need for parentheses.

PHP 5.4 (Released March 2012)

  • Traits : Allows code reuse in single-ancestor programming languages, a kind of multiple inheritance.
  • Short Array Syntax : It is now possible to declare arrays with square brackets [] instead of using the array() function.
  • Improved memory management : Reduces overall memory usage.

PHP 5.5 (Released June 2013)

  • Generators : Allows the easy creation of iterators without the need to implement the iterator interface.
  • Finally keyword : Helps ensure that a segment of code is always executed, regardless of whether an exception is thrown.
  • Support for lists in foreach.

PHP 5.6 (Released August 2014)

  • Argument Unpacking : Allows you to use ... to unpack arguments from an array or a Traversable object.
  • Use function and use const : Import functions and constants into a namespace.
  • GMP improvements : Allows the use of GMP numbers in functions that accept integers or strings.
  • Security improvements : Support for public key signing certificates is added.

PHP 7 (Released in 2015)

With PHP 7, a huge leap in performance was made thanks to the introduction of the Just In Time (JIT) execution engine. Additional features include return types, scalar type declaration, null merge operator, and the ability to define constant arrays using define().

PHP 7.0 (Released in December 2015)

  • Performance improvement : The new PHPNG engine (Zend Engine 3) improves performance, reduces memory usage and facilitates error handling.
  • Return type declarations : This feature allows you to specify the type of value that a function should return.
  • Scalar type declarations : Allows forcing the type of parameters in functions (int, float, string, bool).
  • Null Fusion Operator (??) : This operator simplifies checking for null values.
  • Spaceship operator (<=>) : Introduced to facilitate comparison between two expressions.

PHP 7.1 (Released December 2016)

  • Nullable types : It is allowed to indicate that the return value of a function can be of a specific type or null.
  • Void functions : The void type is introduced for functions that do not return anything.
  • Class constant visibility : You can now define class constants as public, private or protected.
  • Iterable pseudo-type : Enter the iterable type for the parameters and the return types of the functions.

PHP 7.2 (Released in November 2017)

  • Libsodium : This library for modern and secure cryptography is now included by default.
  • Type enhancements : Added the "object" type and allowed the use of abstract types in parameter types and return type declarations.

PHP 7.3 (Released December 2018)

  • Trailing commas in function calls : Trailing commas are allowed in function calls.
  • JSON code speed improvement : The performance of the json_encode() and json_decode() functions has been improved.
  • GC improvements : Introduces improvements to the garbage collector, resulting in lower memory usage.

PHP 7.4 (Released in November 2019)

  • Arrow functions : This feature allows the creation of anonymous functions in a more concise way.
  • Typed properties : Class properties can now have declared types.
  • Unpacking inside arrays : This feature allows unpacking arrays inside other arrays.
  • Weak references : Allows the retention of references to objects without preventing them from being destroyed by the garbage collector.

PHP 8 (Released in 2020)

PHP version 8 brought with it a number of exciting new features, such as Just-In-Time (JIT) compilation, which further improves performance. Union data types, match expressions, nullsafe operator, named arguments, and attributes were also added, among many other features.

Well, and where is version 6?

The PHP 6 version did, in fact, exist as a project, but was never officially released . The main goal of PHP 6 was to provide native support for Unicode, a standard that allows text processing in any language in the world.

However, the developers ran into a number of problems during development . Implementing full Unicode support in the PHP core turned out to be much more of a challenge than expected. Also, the performance of the preview version of PHP 6 with Unicode was significantly slower.

Due to these difficulties and the delay in development, the PHP 6 project was eventually abandoned. The developers decided to skip number 6 when naming the next major version of PHP to avoid confusion with the failed PHP 6 project. Therefore, after PHP 5.6, the next major version was PHP 7.0.

PHP 7 incorporated many of the features planned for PHP 6, but did not include native Unicode support in the language core. Instead, PHP 7 focused on improving performance and adding new features to the language.

Let's talk about performance, is it worth upgrading?

The evolution of the programming language has not only brought new functionality, but special emphasis has also been placed on improving performance with each version:

  • PHP/FI 2.0 - Low . It was not optimized for performance, as the main focus was on form capabilities and interaction with databases.
  • PHP 3 - Improved over PHP/FI 2.0. The rewrite of the PHP engine allowed an improvement in performance and efficiency.
  • PHP 4 - Improved over PHP 3. The introduction of the Zend engine provided a further improvement in performance.
  • PHP 5.0 - Similar to PHP 4. Although it included significant improvements in object-oriented programming and XML support, performance was similar to PHP 4.
  • PHP 5.1 - 5.6 - Improved with each minor release, especially with performance optimizations and garbage collection improvements.
  • PHP 7.0 - Significantly improved over PHP 5.X, thanks to the introduction of Zend Engine 3. The performance of PHP 7.0 could be double or triple that of PHP 5.6 for many applications.
  • PHP 7.1 - 7.4 - Each minor version introduced performance improvements, though not as drastic as the jump from PHP 5.6 to PHP 7.0.
  • PHP 8.0 - Improved over PHP 7.4. The addition of Just-In-Time (JIT) compilation can improve performance in certain cases, although the improvement may not be significant for typical web applications.

And security? What can you tell me?

PHP/FI 2.0 - PHP 3

  • In these early versions, security was not a major concern and many security features were not included.

PHP4

  • PHP 4 introduced safe_mode, which was intended to prevent some types of attacks, but was ultimately deemed ineffective and was deprecated and removed in PHP 5.4.

PHP5

PHP 5 introduced a number of security improvements:

  • Magic Quotes: Introduced to prevent SQL injection attacks, but was criticized for inconsistent behavior and was eventually disabled by default in PHP 5.3 and removed in PHP 5.4.
  • Error handling improvements: PHP 5 introduced exceptions, which improve error handling and can help prevent the exposure of sensitive information.
  • PDO (PHP Data Objects): Introduced in PHP 5.1, it provides an interface for accessing databases that includes prepared queries, which can help prevent SQL injection.

PHP 5.2

  • Input Filter: PHP 5.2 introduced the filter extension that allows validation and filtering of input data in a secure and consistent manner.

PHP 5.3

  • PHAR (PHP Archive): PHP 5.3 introduced support for PHAR, a way to package entire PHP applications into a single archive. Although this is not a security enhancement itself, PHAR includes several security measures to prevent attacks, such as the ability to validate digital signatures.

PHP 5.6

  • SSL/TLS security improvement: PHP 5.6 introduced support for public key signing certificates and improvements to the default SSL/TLS settings.

PHP 7

PHP 7 disabled or removed several outdated and potentially insecure functions and features:

  • Removed several insecure hash functions, such as crypt() and hash().
  • Disabled automatic deserialization to prevent object injection vulnerability.
  • Introduced type declaration and return type declaration to help prevent type errors that could be exploited.

PHP 7.2

  • Password security enhancement: PHP 7.2 introduced the password_hash() function with support for Argon2, a more secure password hashing algorithm.

PHP 8

PHP 8 didn't introduce many new security features, but it continued the PHP 7 trend of removing or disabling outdated and potentially insecure features.

Conclusion

Upgrading to the latest version of PHP often offers several benefits . First, updates often include performance improvements , which can make your web applications run faster. Second, newer versions often include new features that can make code more efficient and easier to write and maintain. Third, newer versions of PHP often include security enhancements that can protect your application against attacks and vulnerabilities.

However, it's also important to note that upgrading to a new version of PHP can bring challenges . Existing code may need to be revised or refactored to support new features or to avoid features that have been disabled or removed. In either case, updating PHP is an essential part of running a secure, high-performance web application .