Safekipedia

PHP

Adapted from Wikipedia · Discoverer experience

A screen showing custom PHP programming code, useful for learning about software development.

PHP is a general-purpose scripting language designed for web development. It was created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released to the public in 1995. Originally, PHP stood for Personal Home Page, but today it means PHP: Hypertext Preprocessor, a recursive backronym.

PHP code runs on a web server. When a server processes PHP, it uses a special program called an interpreter to turn the code into something like a web page. This allows PHP to create parts of websites dynamically, such as showing the current date or pulling information from a database.

Because PHP is free software and can work on many different types of computers, it has become one of the most popular languages for building websites. Many tools and systems make it easier to use PHP, helping developers create everything from simple pages to large online services.

History

The PHP language started in 1993 when Rasmus Lerdorf created some tools to manage his personal homepage using Common Gateway Interface programs. He made these tools work with HTML forms and databases, naming them "Personal Home Page/Forms Interpreter" or PHP/FI.

An example of PHP code for the WordPress content management system.

PHP/FI could build simple and dynamic web applications. It was first shared publicly in 1995 and grew quickly. Over time, more people joined to help develop PHP.

In 1997, Zeev Suraski and Andi Gutmans redesigned PHP, which led to PHP 3. They continued improving it, creating PHP 4 in 2000 and PHP 5 in 2004. Each new version added important features and made PHP more powerful.

Later versions, like PHP 7 and PHP 8, focused on making the language faster and easier to use. These updates helped PHP stay popular for building websites and web applications.

VersionRelease dateSupported until
Unsupported: 1.08 June 1995
Unsupported: 2.01 November 1997
Unsupported: 3.06 June 199820 October 2000
Unsupported: 4.022 May 200023 June 2001
Unsupported: 4.110 December 200112 March 2002
Unsupported: 4.222 April 20026 September 2002
Unsupported: 4.327 December 200231 March 2005
Unsupported: 4.411 July 20057 August 2008
Unsupported: 5.013 July 20045 September 2005
Unsupported: 5.124 November 200524 August 2006
Unsupported: 5.22 November 20066 January 2011
Unsupported: 5.330 June 200914 August 2014
Unsupported: 5.41 March 20123 September 2015
Unsupported: 5.520 June 201310 July 2016
Unsupported: 5.628 August 201431 December 2018
6.xNot released—N/a
Unsupported: 7.03 December 201510 January 2019
Unsupported: 7.11 December 20161 December 2019
Unsupported: 7.230 November 201730 November 2020
Unsupported: 7.36 December 20186 December 2021
Unsupported: 7.428 November 201928 November 2022
Unsupported: 8.026 November 202026 November 2023
Unsupported: 8.125 November 202131 December 2025
Supported: 8.28 December 202231 December 2026
Supported: 8.323 November 202331 December 2027
Supported: 8.421 November 202431 December 2028
Latest version: 8.520 November 202531 December 2029
Legend:
Unsupported
Supported
Latest version
Preview version
Future version

Mascot

The mascot of the PHP project is the elePHPant, a blue elephant with the PHP logo on its side, designed by Vincent Pontier in 1998. When you look at the PHP letters from the side, they form the shape of an elephant.

The elePHPant comes in different colors, especially as plush toys. Many versions of this mascot have been made over the years, but only those based on Vincent Pontier's original design are considered official. These elePHPants are collectable, and some rare ones are very hard to find.

Syntax

PHP is a language used to build websites. You can mix PHP code with HTML to create dynamic pages. PHP code is placed inside special tags, and only that code is processed by the PHP interpreter. Everything else is treated as normal content.

Variables in PHP start with a dollar sign ($). Unlike some other languages, you don’t need to specify what kind of data a variable will hold before using it. PHP can handle many types of data, including whole numbers, decimals, and text. It also has special types for true/false values and for handling resources like files or databases.

Implementations

The main version of PHP is called simply PHP, and it uses something called the Zend Engine to run PHP code. The Zend Engine changes PHP code into a special format so it can be used by computers.

To make PHP run faster, tools like Zend Opcache help by storing already-processed PHP code so it doesn’t need to be processed again each time. There are also other versions of PHP made by different groups. One example is HHVM, created by Facebook, which changes PHP code into another format to make it run even faster. Other tools like Parrot, PeachPie, Phalanger, and Quercus also try new ways to run PHP code quickly.

Licensing

PHP is free software released under the PHP License, which is similar to the 3-clause BSD license. Earlier versions of PHP had stricter rules, including limits on how the name "PHP" could be used in related products. These rules made older PHP licenses incompatible with other common software licenses.

Development and community

PHP works with many free and open-source libraries and has built-in tools to connect with servers and databases like PostgreSQL, MySQL, Microsoft SQL Server, and SQLite. Developers can add new features to PHP by writing extensions in the C programming language. These extensions can be added directly into PHP or loaded when needed.

PHP is mainly used for building websites, but it can also be used for other tasks, like controlling drones. There are community projects that help make creating these extensions easier. The PHP Group, which helps guide the language, includes several key developers who have contributed to PHP over the years.

The PHP Foundation

On 26 November 2021, the JetBrains blog announced the creation of The PHP Foundation, which will sponsor the design and development of PHP. The foundation hires "Core Developers" to work on the PHP language's core repository. Germany's Sovereign Tech Fund provided more than 200,000 Euros to support the PHP Foundation.

The response to the foundation has been largely positive, with commentators praising its role in ensuring the continued development of PHP and helping to stabilise the language's community and popularity.

YearCommitsReviewsRFCs
20226832838
202378470217
20241976127813

Installation and configuration

Example output of the phpinfo() function in PHP 7.1

PHP can be added to a web server in two main ways: as a module that works directly with the server, or as a separate program that the server calls when needed. Many popular web servers, like Apache HTTP Server and Microsoft IIS, support PHP modules. If a server doesn’t support PHP modules, PHP can still be used by running it as a separate program.

PHP also has special tools for running commands from the computer’s command line and can be used to create programs outside of a web server. There are many settings that can be adjusted to change how PHP works, usually found in a file called php.ini.

Use

PHP is a general-purpose scripting language that works very well for creating websites. It can run on many different types of computers and works with lots of databases. People often use PHP to make web pages change based on what the visitor does, like showing different news or pictures.

PHP is especially popular for building websites. Many big website tools, like WordPress and Drupal, use PHP. In fact, PHP is used by most websites that need a programming language to work behind the scenes. It’s free to use, and many people around the world help improve it all the time.

Security

PHP has had security issues over the years. In 2019, 11% of all listed computer problems were related to PHP. Some old PHP settings, like magic_quotes_gpc and register_globals, made websites easier to hack. These settings are no longer used in newer PHP versions.

PHP also has some tricks with numbers and text that can cause problems. For example, it might think two different things are the same when they are not, which can let hackers break into websites. Developers are advised to use special functions like hash_equals() to compare things safely.

Cryptographic security

PHP used to have functions for random numbers that were not very safe. Now, in version 8.1 and later, there is a better function called random_int() that is safer to use.

Long-term support

PHP gets regular updates to fix problems. Each small version gets updates for two years, and then only important security updates for another two years. After that, PHP stops getting updates unless special paid support is bought from companies like Zend.

Images

Portrait of Rasmus Lerdahl at a technology conference.
Portrait of Andi Gutmans, a professional photographer.
Zeev Suraski, a key contributor to the PHP programming language, speaking at a technology conference in Paris in 2005.

Related articles

This article is a child-friendly adaptation of the Wikipedia article on PHP, available under CC BY-SA 4.0.

Images from Wikimedia Commons. Tap any image to view credits and license.