History of PHP language
PHP is a general-purpose scripting language that is used in web development. It was originally created by Rasmus Lerdorf in 1994. At that time, Lerdorf was a very famous Danish Canadian programmer. The mascot of PHP is an elephant, was designed by Vincent Pointier in 1998. If you put an outline on it, then something similar is the idea behind making the PHP logo an elephant. Over time, many variations of this mascot were made, but ultimately the original variant was adopted.
Early Development of PHP
PHP developers started in 1994 when Lord of Personal Web Programming was looking at some CGI programs using the C programming language. He created these programs to manage his personal home base. He called it PHP, the language for creating relative personal home pages. But he extended this work and named it PHP Personal Homepage. That PHP, which we know today as a very famous programming language.
Growth and Popularity
After this, PHP started being used to create simple dynamic web applications, and Lerdorf launched the first version of PHP in 1995. In this release, the basic functionalities of PHP were already present, some tools for form handling were there, and PHP had its own syntax. Many web developers benefited from this release. Its simple and limited consistent syntax increased developers' love for it, and people started having very positive vibes about PHP, which led them to start editing PHP.
From there, PHP evolution started growing rapidly. At that time, the craze for PHP was very high. People saw PHP in such a way that backend development had become very easy. The surprising thing is that Lerdorf never created PHP as a programming language. Due to its popularity and speed, it became so simple that after using PHP, people did not want to switch to another language.
Formation of PHP Development Team
After PHP's massive growth, Lerdorf once said, "I don’t know how to stop this. It is something that is growing in a positive direction. I never intended to create a programming language." These were some of Lerdorf's words. In November 1997, a development team was set up to work on the further development of PHP. As I told you, PHP never grew as a programming language, so a lot of inconsistencies came in its syntax and function names. Because of this, a development team was needed, and a standard was needed to standardize all these things. In 1997, Gutmans started working on PHP 3, and it was released in 1998. In 2000, PHP 4 was released, and its development continued after this.
Major PHP Versions
Version | Release Date | End of Support | Notable Features |
---|---|---|---|
1.0 | June 8, 1995 | N/A | Initial release named "Personal Home Page Tools (PHP Tools)." |
2.0 | April 16, 1996 | N/A | Improved performance and introduced basic functionality for dynamic web pages. |
3.0 | June 6, 1998 | October 20, 2000 | Complete rewrite by Zeev Suraski and Andi Gutmans; established PHP as a standalone language. |
4.0 | May 22, 2000 | June 23, 2001 | Introduced the Zend Engine, enhancing performance and adding support for more complex applications. |
4.1 | December 10, 2001 | March 12, 2002 | Added 'superglobals' ($_GET , $_POST , $_SESSION , etc.) for improved global variable handling. |
4.2 | April 22, 2002 | September 6, 2002 | Disabled register_globals by default to enhance security. |
4.3 | December 27, 2002 | March 31, 2005 | Introduced the Command Line Interface (CLI) for scripting purposes. |
4.4 | July 11, 2005 | August 7, 2008 | Added man pages for phpize and php-config scripts. |
5.0 | July 13, 2004 | September 5, 2005 | Introduced Zend Engine II with a new object model and added support for exceptions. |
5.1 | November 24, 2005 | August 24, 2006 | Improved performance and introduced the PHP Data Objects (PDO) extension for database access. |
5.2 | November 2, 2006 | January 6, 2011 | Enabled the filter extension by default and added native JSON support. |
5.3 | June 30, 2009 | August 14, 2014 | Added support for namespaces, late static bindings, and introduced closures. |
5.4 | March 1, 2012 | September 3, 2015 | Introduced traits, a shortened array syntax, and a built-in web server for development. |
5.5 | June 20, 2013 | July 21, 2016 | Added generators, the finally keyword for exception handling, and integrated the OPcache extension. |
5.6 | August 28, 2014 | December 31, 2018 | Introduced constant scalar expressions, variadic functions, and the exponentiation operator (** ). |
7.0 | December 3, 2015 | December 3, 2018 | Major performance improvements with Zend Engine 3; added scalar type declarations and return type declarations. |
7.1 | December 1, 2016 | December 1, 2019 | Added nullable types, void return type, and class constant visibility modifiers. |
7.2 | November 30, 2017 | November 30, 2020 | Introduced the object type hint and added the Sodium library for modern cryptography. |
7.3 | December 6, 2018 | December 6, 2021 | Added flexible heredoc and nowdoc syntax, and improved JSON error handling. |
7.4 | November 28, 2019 | November 28, 2022 | Introduced typed properties, arrow functions, and preloading for improved performance. |
8.0 | November 26, 2020 | November 26, 2023 | Added Just-In-Time (JIT) compilation, union types, and named arguments. |
8.1 | November 25, 2021 | December 31, 2025 | Introduced enums, readonly properties, and fibers for better asynchronous programming. |
8.2 | December 8, 2022 | December 31, 2026 | Added readonly classes, standalone null, false, and true types, and deprecated dynamic properties. |
8.3 | November 23, 2023 | December 31, 2027 | Introduced typed class constants, the json_validate() function, and deep cloning for readonly properties. |
8.4 | November 21, 2024 | December 31, 2028 | Added property hooks, asymmetric visibility for properties, and lazy objects. |
PHP 6 was never officially released due to various issues during its development.
These are the References of the table:
PHP 4 was based on the Zend Engine. Later, PHP 5 was released with an updated version of the Zend Engine 2. Work on PHP 5 started in July 2004. PHP 5 was considered revolutionary because it introduced Object-Oriented Programming (OOP) and PHP Data Objects (PDO), which were new and highly useful features at that time. Developers were very excited about PHP 5.
After 2018, PHP 5 stopped receiving security updates. PHP 6 experimented with Unicode support, but it was never officially released. As a result, PHP 6 never came into existence. Work on PHP 7 began between 2014 and 2015. A debate arose among developers on whether to name it PHP 6 or PHP 7, since PHP 6 was never officially released. Finally, PHP 7 was released.
In 2020, PHP 8 was released as a stable version. However, PHP's popularity started declining. Developers began criticizing PHP, which led to significant improvements. A JIT compiler was added, and modern programming features were incorporated to keep PHP competitive with modern languages.
PHP Syntax Overview
Let’s see how PHP’s syntax is written and how PHP is actually coded.
The "Hello World" program in PHP is written like this:
<?php
echo "Hello, World!";
?>
PHP Comments
Comments exist in PHP. A comment means that any text you put inside your PHP file will not be executed.
For single-line comments, you will use this:
// This is a single-line comment
For multi-line comments, you can use this method if you want to see your comment in multiple lines:
/*
This is a
multi-line comment
in PHP
*/
Variables in PHP
Variables are like containers that store information.
The variables in PHP can be created like this:
<?php
$name = "John";
$age = 25;
echo "Name: $name, Age: $age";
?>
Predefined Variables in PHP
PHP has predefined variables like $_GET
, $_POST
, $_SESSION
, and $_COOKIE
, which are used to handle user input, sessions, and cookies.
Strings in PHP
A string is a sequence of characters, and in PHP, a string can be created like this:
<?php
$string = "Hello, PHP!";
echo $string;
?>
Integers and Floats in PHP
Numbers can be used for arithmetic operations in PHP, and you can perform arithmetic operations on variables like this:
<?php
$num1 = 10;
$num2 = 20;
$sum = $num1 + $num2;
echo "Sum: $sum";
?>
If you want to print information from any variable in PHP, you can use the "echo" function like this:
<?php
$message = "Welcome to PHP!";
echo $message;
?>
This will print all the simple information you provide.
Arrays in PHP
Arrays can be created in PHP like this:
<?php
$colors = array("Red", "Green", "Blue");
echo $colors[0]; // Output: Red
?>
Conditional Statements in PHP
In PHP, you can use conditional statements.
You can use "if" statements to execute a condition like this:
<?php
$age = 18;
if ($age >= 18) {
echo "You are eligible to vote.";
}
?>
And if you want to write an "else" statement in PHP, it looks like this:
<?php
$age = 16;
if ($age >= 18) {
echo "You are eligible to vote.";
} else {
echo "You are not eligible to vote.";
}
?>
PHP supports switch statements, and the syntax is like this:
<?php
$day = "Monday";
switch ($day) {
case "Monday":
echo "It's the start of the week.";
break;
case "Friday":
echo "Weekend is coming!";
break;
default:
echo "It's just another day.";
}
?>
Loops in PHP
Loops can be used in PHP.
Loops mean that if you want to perform any action multiple times, you can use "for" and "while" loops like this.
The "for" loop syntax in PHP is like this:
<?php
for ($i = 1; $i <= 5; $i++) {
echo "Iteration: $i <br>";
}
?>
The "while" loop syntax in PHP is like this:
<?php
$i = 1;
while ($i <= 5) {
echo "Iteration: $i <br>";
$i++;
}
?>
PHP also has a "foreach" loop, which allows you to iterate over arrays like this:
<?php
$fruits = array("Apple", "Banana", "Cherry");
foreach ($fruits as $fruit) {
echo "$fruit <br>";
}
?>
Additionally, you can also use "do-while" loops in PHP like this:
<?php
$i = 1;
do {
echo "Iteration: $i <br>";
$i++;
} while ($i <= 5);
?>
PHP is an object-oriented programming language. Inside PHP, people can create objects through classes. A class is a blueprint because it is used to create objects, and an object is an instance of that class which is created using that template blueprint. If a class is a template, then an object is an instance made with the help of a blueprint.
Objects and Classes syntax can be written something like this:
<?php
// Defining a class
class Car {
// Properties
public $brand;
public $color;
// Constructor method
public function __construct($brand, $color) {
$this->brand = $brand;
$this->color = $color;
}
// Method to display car details (using PHP_EOL for CLI compatibility)
public function displayInfo() {
echo "Brand: " . $this->brand . ", Color: " . $this->color . PHP_EOL;
}
}
// Creating objects (instances) of the class
$car1 = new Car("Toyota", "Red");
$car2 = new Car("Honda", "Blue");
// Calling methods on objects
$car1->displayInfo();
$car2->displayInfo();
?>
Final Note:
PHP is getting quite improved, and definitely evolving as a stable language. This simple to use, beginner-friendly language that people can use for the web. I hope you really liked this history of PHP and understood how to use PHP.
Top comments (2)
The graphic shows the situation until 2022, with PHP 7.4 as the highest used language version. That is just outdated. A more up to date one is this one. Still scary to see people use end of life php versions, lower than 8.2.
That is just rewriting history. The JIT compiler is added to the first PHP 8 version, it is not added as a reaction to critical developers, because then it would be in a PHP 9 version. JIT is one of the main reasons the major version number changed.
There is a better
switch
in PHP, match.PHP is a multi-paradigm language. It is procedural if you don't use objects. It is object-oriented if you do use objects. And it has some functional capabilities like higher order functions and immutable objects.
The current way of writing a class is
Type hinting has become very common in PHP code.
You should never use echo in a class method. That makes the class method only usable as part of the output. Most of the times php applications use a templating engine, and that is in charge of the output.
Jumping from procedural code to object-oriented code is a huge step in terms of computer science knowledge. Just showing the syntax works with procedural code, but for object-oriented code there are a few concepts you have to understand before you should start using it.
Thanks for pointing out the version release timeline:
I have updated it using table for better understanding.
And I have provided the reference links where I have fetched that data.