Question mark

What is PHP?

Today, we will describe what the PHP programming language is. You probably have heard a lot about it, and even wrote some basic scripts. But if you'd like to learn history or language concepts, then reading this article is the right choice to do.

The first version of this language was released many years ago, back on the 8th of June 1995. During the time, many core components were changed, but the general direction and philosophy stayed almost the same. That's a scripting language, which is used mostly in web sites or online applications. Also, it's simple, easy to use, and can be learned very quickly.

We’ll briefly describe each version, so you can see how it was evolving over the time.

PHP 1 and 2

The initial version of this very well known and commonly used programming language was created by Rasmus Lerdorf. In the beginning, it was a simple collection of scripts to track access to his public resume. But after some time, the product evolved, many new features were added. In 1994, the source code was given to the public and anyone could review, test or improve the language core functionality.

PHP 3 and 4

The language parser has been completely rewritten by the team and included in version 3 of the PHP. Also, the name of the product was changed from "Personal Home Page Tools (PHP Tools)" to "PHP: Hypertext Preprocessor". As you can see, the new name is a reverse acronym, which is an acronym that refers to itself.

PHP 5

After some period of development and iterations, version 5 of the PHP was released in July 2004. This release includes many new features and major improvements, for example, Zend Engine II, PDO extension, extended Object-Oriented Programming support, better performance, etc.

PHP 6

The goal of this version was to support Unicode characters in the core. However, due to various issues and delays in the development, this version was never released to the public. Instead, the PHP language team took some features out of the internal PHP 6 version and added them to version 5.3, which included namespaces. Also, later, traits and re-binding options were added into PHP 5.4 core.

PHP 7

This was a very major step forward, many components of the core have been changed, and custom PHP scripts started to work much faster.

The most important new features are:

  • Return type declarations. Now you can set the type of variable that can be returned from a function.
  • You can now create custom arrays in define() operator.
  • new class statement which can define anonymous classes.
  • intdiv() function to perform an integer division.
  • The null coalescing operator. This statement returns the first operand if it's not null and exists, otherwise the second operand is returned.
  • The spaceship operator. It can be used for comparing various expressions.
  • And many others, which you can find in the official PHP documentation.

PHP 8

This version contains the Just in Time compilation (JIT) feature, which is added with a goal to improve performance and reduce execution time.

In conclusion, PHP is a well-known language that is adopted very widely. It allows developers to make code of any complexity. Such popular content management systems, like WordPressDrupalMagento, and many other tools are all written in PHP.

PHP 8.1

That's a very important update, since it contains a lot of new features. In addition, there are many fixes, improvements and speed optimizations. New version of the language now supports enums that allow defining a type that is bound to some set of values.

Also, developers can create "readonly" properties inside of some classes. Such a design will not allow modifying the value after its initialization. Please see the following code sample that shows how this property can be used.

<?php

class Rectangle {
    public readonly string $width;
    public readonly string $height;

    public function __construct(int $width, int $height) {
        $this->width = $width;
        $this->height = $height;
    }

    public function getArea() {
        return $this->width * $this->height;
    }
}

$sample_rectangle = new Rectangle(10, 20);

echo 'AREA: ' . $sample_rectangle->getArea();

?>

The console output of the given PHP code is shown below.

AREA: 200

It is worth mentioning that there are much more interesting features in PHP 8.1, like the final class constants, fibers, pure Intersection types and others. To get a more detailed overview, you may want to open the official PHP documentation and see a detailed description for this release of the PHP.

Conclusion

As you see, PHP is a very mature language and has a long history of improvements. It is widely adopted and used in many popular web applications. Also, it's worth mentioning that the PHP is actively maintained. As a result, we may expect to see some new interesting features added to the future versions of the language.

Thank you for spending your time with us. We hope this article was helpful for you.

Related Articles

Digital clock on computer

How to get the current date and time in PHP

Man typing on laptop

How to send AJAX request in the WordPress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *