The evolution of PHP from 5.4 to 8.3, and what has changed.

Faraz Mobin
3 min readJun 18, 2024

--

The evolution of PHP from version 5.4 to 8.3 represents a significant transformation in terms of performance, features, and best practices. Here’s an overview of the key changes and improvements across these versions:

PHP 5.4 (Released March 2012)

- Traits: Introduced to allow for code reuse in single inheritance languages.
- Short Array Syntax: Added shorthand for array declarations, `[]` instead of `array()`.
- Built-in Web Server: A built-in CLI web server was introduced for development purposes.
- Dereferencing: Array dereferencing for function calls, e.g., `foo()[0]`.

PHP 5.5 (Released June 2013)

- Generators: Introduced for implementing simple iterators.
- `finally` keyword: Added for exception handling.
- Password Hashing API: Simplified password hashing and verification.
- `yield` keyword: Introduced for generators.

PHP 5.6 (Released August 2014)

- Variadic Functions: Added support for functions to accept variable numbers of arguments.
- Argument Unpacking: Using the `…` operator.
- Constant Scalar Expressions: Allowed constant expressions in constants, property declarations, etc.
- Exponentiation Operator: `**` added for exponentiation.

PHP 7.0 (Released December 2015)

- Performance: Significant performance improvements, often twice as fast as PHP 5.6.
- Scalar Type Declarations: Allow for more precise type hinting (e.g., `int`, `float`, `string`, `bool`).
- Return Type Declarations: Functions can declare their return type.
- Coalescing Operator `??` operator introduced.
- Spaceship Operator `<=>` operator for three-way comparisons.
- Anonymous Classes: Support for creating classes without names.

PHP 7.1 (Released December 2016)

- Nullable Types: Allow type declarations to be null (e.g., `?string`).
- Void Return Type: Indicate that a function does not return a value.
- Class Constant Visibility: Constants can have `public`, `protected`, or `private` visibility.
- Iterables: `iterable` type hint for arrays and traversable objects.

PHP 7.2 (Released November 2017)

- Object Type: `object` type hint added.
- Parameter Type Widening: Relaxation of inheritance rules for parameter types.
- Argon2: Added as a password hashing algorithm.
- Libsodium: Sodium (a modern cryptography library) added.

PHP 7.3 (Released December 2018)

- Flexible Heredoc and Nowdoc Syntax: Improved flexibility for multiline string declarations.
- JSON_THROW_ON_ERROR: Option to throw exceptions on JSON errors.
- `is_countable` Function: Added to check if a variable is countable.
- Array Destructuring: Extended to support reference assignments.

PHP 7.4 (Released November 2019)

- Typed Properties: Type declarations for class properties.
- Arrow Functions: Short closures using `fn` keyword.
- Null Coalescing Assignment Operator: `??=`.
- Preloading: Scripts can be preloaded to improve performance.
- Deprecations: Several features were deprecated in preparation for PHP 8.

PHP 8.0 (Released November 2020)

- Just-in-Time (JIT) Compilation: Significant performance improvements.
- Union Types: Support for multiple types (e.g., `int|float`).
- Named Arguments: Call functions with named arguments.
- Attributes: Meta-data annotations for classes, methods, properties, etc.
- Constructor Property Promotion: Simplify constructor property assignments.
- Match Expression: An enhanced `switch` alternative.
- Static Return Type: Allow methods to specify a `static` return type.

PHP 8.1 (Released November 2021)

- Enums: Native support for enumerations.
- Fibers: Lightweight, stackful coroutines for better asynchronous programming.
- Readonly Properties: Properties that can only be written once.
- Intersection Types: Combine multiple types (e.g., `A&B`).
- Array Unpacking with String Keys: Improved array unpacking.

PHP 8.2 (Released December 2022)

- Readonly Classes: Classes where all properties are readonly.
- Disjunctive Normal Form Types: Complex type unions.
- `#[\SensitiveParameter]` Attribute: Mark parameters that should be treated as sensitive.
- `AllowDynamicProperties` Attribute: Control dynamic property declarations.

PHP 8.3 (Released November 2023)

- New Features and Improvements: Further refinements and new functionalities, though specific details depend on the latest updates and RFCs approved for this version.

This evolution highlights PHP’s transition from a simple scripting language to a powerful, type-safe, and high-performance language suitable for modern web development.

Watch this video from PHP annotated: https://youtu.be/p_6ewdiwnRo?si=hEuU9LdcF-jQqc3n

--

--

Faraz Mobin

Hello I am Faraz and I love Web Development and I am a freelancer. I doing web dev frompast 1 year. I Love to build websites.