An introduction to PHP
This chapter ....
Table of contents
Introduction
PHP is a popular general-purpose scripting language that is especially suited to web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1994. For the first 20 years, PHP had no written specification. I think it is safe to say that it will not win any design awards. However, in 2021, PHP is by far the main platform for the interactive websites. According to W3Techs, it has a 79 % share of the market for server-side programming languages. That means it is likely to stay in the site-builders toolschest for some time.
PHP versions
A brief History of PHP, up to PHP 5 (2004) is on php.net.
There was no PHP 6. For PHP 7, see Vilson Duka: Introduction To PHP 7.
Links to pages listing backward incompatible changes from PHP 7 and onwards:
- PHP 5.6 → 7.0 (2015)
- PHP 7.0 → 7.1 (2016)
- PHP 7.1 → 7.2 (2017)
- PHP 7.2 → 7.3 (2018)
- PHP 7.3 → 7.4 (2019)
- PHP 7.4 → 8.0 (2020)
- PHP 8.0 → 8.1 (2021)
- PHP 8.1 → 8.2 (2022)
The table below shows the PHP versions supported by various versions of Drupal core at the time of writing (2023-09-18):
You may also want to see: PHP.net: Supported Versions.
PHP version | Drupal core | Recommended | |
---|---|---|---|
version | D9? | D10? | |
5.5 | None | - | - |
5.6 | ^7 | - | - |
7.1 | ^7, ^8 | - | - |
7.2 | ^7, ^8 | - | - |
7.3 | ^7, ^8, ^9 | No | - |
7.4 | ^7.71, ^8, ^9 | No | - |
8.0 | ^9 | Yes | - |
8.1 | ^9.5, ^10 | Yes | Yes |
8.2 | ^10 | - | Yes |
Sources: Drupal.org PHP requirements (D7) and PHP requirements (D8+).
The latest version of PHP 8.2, was released 2022-12-08. The default versions that ships with Ubuntu LTS are:
- Ububtu 14.04 LTS: PHP 5.5.9.
- Ububtu 18.04 LTS: PHP 7.2.24.
- Ububtu 20.04 LTS: PHP 7.4.3.
- Ububtu 22.04 LTS: PHP 8.1.2.
You may specify the minimum PHP version (see
.info.yml
example)
like this:
php: 8.0
Learning PHP
Below are some pointers to online materials about PHP.
- Drupal.org: OO programming conventions.
Drupal-specific conventions. - dice.com: A quick introduction to a complex language.
A one page introduction to PHP 7.0. - codecademy.com: Learn PHP.
A full course going from basics to OOP. Some parts are behind a paywall. - phpenthusiast.com: Learn Object-oriented PHP.
A clean, well written, and logical progression through the basics of PHP OOP.
Final word
You may also want to read SO: PHP errors explained.
Last update: 2023-09-18 [gh].