Share to: share facebook share twitter share wa share telegram print page

PHP

PHP
ParadigmMulti-paradigm: imperative, functional, object-oriented, procedural, reflective
Designed byRasmus Lerdorf
DeveloperThe PHP Development Team, Zend Technologies, PHP Foundation
First appeared8 June 1995; 30 years ago (1995-06-08)[1][2]
Stable release
8.4.12[3] Edit this on Wikidata / 28 August 2025; 33 days ago (28 August 2025)
Typing disciplineDynamic, weak, gradual[4]
Implementation languageC (primarily; some components in C++)
OSUnix-like, Windows, macOS, IBM i, OpenVMS, IBM Z
LicensePHP License[a]
Filename extensions.php,.phar,.phtml,.pht,.phps
Websitephp.net
Major implementations
Zend Engine, HHVM, PeachPie, Quercus, Parrot
Influenced by
Perl, C, C++, Java,[6] Tcl,[2] JavaScript[7]
Influenced
Hack, JSP, ASP, React JS
  • PHP Programming at Wikibooks

PHP is a general-purpose scripting language geared towards web development.[8] It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995.[9][10] The PHP reference implementation is now produced by the PHP Group.[11] PHP was originally an abbreviation of Personal Home Page,[12][13] but it now stands for the recursive backronym PHP: Hypertext Preprocessor.[14]

PHP code is usually processed on a web server by a PHP interpreter implemented as a module, a daemon or a Common Gateway Interface (CGI) executable. On a web server, the result of the interpreted and executed PHP code—which may be any type of data, such as generated HTML or binary image data—would form the whole or part of an HTTP response. Various web template systems, web content management systems, and web frameworks exist that can be employed to orchestrate or facilitate the generation of that response. Additionally, PHP can be used for many programming tasks outside the web context, such as standalone graphical applications[15] and drone control.[16] PHP code can also be directly executed from the command line.

The standard PHP interpreter, powered by the Zend Engine, is free software released under the PHP License. PHP has been widely ported and can be deployed on most web servers on a variety of operating systems and platforms.[17]

The PHP language has evolved without a written formal specification or standard, with the original implementation acting as the de facto standard that other implementations aimed to follow.

W3Techs reports that as of 27 October 2024 (about two years since PHP 7 was discontinued and 11 months after the PHP 8.3 release), PHP 7 is still used by 50.0% of PHP websites, which is outdated and known to be insecure.[18][19] In addition, 13.2% of PHP websites use the even more outdated (discontinued for 5+ years) and insecure PHP 5, and the no longer supported PHP 8.0 is also very popular, so the majority of PHP websites do not use supported versions.

History

Rasmus Lerdorf, creator of PHP; and Andi Gutmans and Zeev Suraski, creators of the Zend Engine

Early history (1993 to 1997)

PHP development began in 1993[9] when Rasmus Lerdorf wrote several Common Gateway Interface (CGI) programs in C,[20][21] which he used to maintain his personal homepage. He extended them to work with web forms and to communicate with databases, and called this implementation "Personal Home Page/Forms Interpreter" or PHP/FI.

An example of the early PHP syntax:[22]

<!--include /text/header.html-->

<!--getenv HTTP_USER_AGENT-->
<!--if substr $exec_result Mozilla-->
  Hey, you are using Netscape!<p>
<!--endif-->

<!--sql database select * from table where user='$username'-->
<!--ifless $numentries 1-->
  Sorry, that record does not exist<p>
<!--endif exit-->
  Welcome <!--$user-->!<p>
  You have <!--$index:0--> credits left in your account.<p>

<!--include /text/footer.html-->

PHP/FI could be used to build simple, dynamic web applications. To accelerate bug reporting and improve the code, Lerdorf initially announced the release of PHP/FI as "Personal Home Page Tools (PHP Tools) version 1.0" on the Usenet discussion group comp.infosystems.www.authoring.cgi on 8 June 1995.[1][23] This release included basic functionality such as Perl-like variables, form handling, and the ability to embed HTML. By this point, the syntax had changed to resemble that of Perl, but was simpler, more limited, and less consistent.[12][11]

Early PHP was never intended to be a new programming language; rather, it grew organically, with Lerdorf noting in retrospect: "I don't know how to stop it [...] there was never any intent to write a programming language [...] I have absolutely no idea how to write a programming language [...] I just kept adding the next logical step on the way."[24] A development team began to form and, after months of work and beta testing, officially released PHP/FI 2 in November 1997.[25]

The fact that PHP was not originally designed, but instead was developed organically has led to inconsistent naming of functions and inconsistent ordering of their parameters.[26] In some cases, the function names were chosen to match the lower-level libraries which PHP was "wrapping",[27] while in some very early versions of PHP the length of the function names was used internally as a hash function, so names were chosen to improve the distribution of hash values.[28]

PHP 3 and 4 (1998 to 2004)

This is an example of PHP code for the WordPress content management system.

Zeev Suraski and Andi Gutmans rewrote the parser in 1997 and formed the base of PHP 3, changing the language's name to the recursive acronym PHP: Hypertext Preprocessor.[11][29] Afterwards, public testing of PHP 3 began, and the official launch came in June 1998. Suraski and Gutmans then started a new rewrite of PHP's core, producing the Zend Engine in 1999.[30] They also founded Zend Technologies in Ramat Gan, Israel.[11]

On 22 May 2000, PHP 4.0, powered by the Zend Engine 1.0, was released.[11] By August 2008, this branch had reached version 4.4.9. PHP 4 is now no longer under development and nor are any security updates planned to be released.[31][32]

Early PHP 5 (2004 to 2006)

On 1 July 2004, PHP 5.0 was released, powered by the new Zend Engine 2.0.[11] PHP 5.0 included significant changes to the language, most notably an overhauled approach to object-oriented programming, as well as iterators and exceptions.[33].

PHP 5.1 and PHP 5.2 were released the following years, adding smaller improvements and new features, such as the PHP Data Objects (PDO) extension (which defines a lightweight and consistent interface for accessing databases) In 2008, PHP 5.x became the only stable version under development.

Many high-profile open-source projects ceased to support PHP 4 in new code from February 5, 2008, because of the GoPHP5 initiative,[34] provided by a consortium of PHP developers promoting the transition from PHP 4 to PHP 5.[35][36]

PHP 6 and Unicode

PHP's native string functions worked only on raw bytes, making use with multibyte character encodings difficult.[37][38] In 2005, a project headed by Andrei Zmievski was initiated to bring native Unicode support throughout PHP, by embedding the International Components for Unicode (ICU) library, and representing text strings as UTF-16 internally.[39] Since this would cause major changes both to the internals of the language and to user code, it was planned to release this as version 6.0 of the language, along with other major features then in development.[40]

However, a shortage of developers who understood the necessary changes, and performance problems arising from conversion to and from UTF-16, which is rarely used in a web context, led to delays in the project.[41] As a result, a PHP 5.3 release was created in 2009, and in March 2010, the project in its current form was officially abandoned, and a PHP 5.4 release was prepared to contain most remaining non-Unicode features from PHP 6.[42] Initial hopes were that a new plan would be formed for Unicode integration, but by 2014 none had been adopted.[citation needed]

Later PHP 5 (2009 to 2014)

Because it contained features originally intended to be part of 6.0, PHP 5.3 was a significant release, adding support for namespaces, closures, late static binding[43][44], and many fixes and improvements to standard functions.

With the Unicode branch officially abandoned, a new release process was adopted in 2011, planning a yearly release cycle, and a clear distinction between "feature releases" (x.y.z to x.y+1.z) and "major releases" (x.y.z to x+1.0.0).[45] Remaining features which had been planned for the 6.0 release were included in PHP 5.4, released in March 2012, such as trait support and a new "short array syntax". This was followed by more incremental changes in PHP 5.5 (June 2013) and 5.6 (August 2014).

For PHP versions 5.3 and 5.4, the only available Microsoft Windows binary distributions were 32-bit IA-32 builds,[46][47] requiring Windows 32-bit compatibility mode while using Internet Information Services (IIS) on a 64-bit Windows platform. PHP version 5.5 made the 64-bit x86-64 builds available for Microsoft Windows.[48]

Official security support for PHP 5.6 ended on 31 December 2018.[49]

PHP 7.x (2015 to 2019)

During 2014 and 2015, a new major PHP version was developed, PHP 7.0. The numbering of this version involved some debate among internal developers.[50] While the PHP 6 Unicode experiments had never been released, several articles and book titles referenced the PHP 6 names, which might have caused confusion if a new release were to reuse the name.[51] After a vote, the name PHP 7 was chosen.[52]

The foundation of PHP 7.0 is a PHP branch that was originally dubbed PHP next generation (phpng). It was written by Dmitry Stogov, Xinchen Hui and Nikita Popov,[53] and aimed to optimize PHP performance by refactoring the Zend Engine while retaining near-complete language compatibility.[54] By 14 July 2014, WordPress-based benchmarks, which served as the main benchmark suite for the phpng project, showed an almost 100% increase in performance. Changes from phpng make it easier to improve performance in future versions, as more compact data structures and other changes are seen as better suited for a successful migration to a just-in-time (JIT) compiler.[55] Because of the significant changes, the reworked Zend Engine was called Zend Engine 3, succeeding Zend Engine 2 used in PHP 5.x.[56]

Because of the major internal changes in phpng, it must receive a new major version number of PHP, rather than a minor PHP 5 release, according to PHP's release process.[45] Major versions of PHP are allowed to break backward-compatibility of code and therefore PHP 7 presented an opportunity for other improvements beyond phpng that require backward-compatibility breaks.[citation needed] In particular, it involved the following changes:

  • Many fatal or recoverable-level legacy PHP error mechanisms were replaced with modern object-oriented exceptions.[57]
  • The syntax for variable dereferencing was reworked to be internally more consistent and complete, allowing the use of the operators ->, [], (),{}, and ::, with arbitrary meaningful left-side expressions.[58]
  • The behavior of the foreach statement was changed to be more predictable.[59]
  • Constructors for the few classes built-in to PHP which returned null upon failure were changed to throw an exception instead, for consistency.[60]
  • Several unmaintained or deprecated server application programming interfaces (SAPIs) and extensions were removed from the PHP core, most notably the legacy mysql extension.[61]
  • The behavior of the list() operator was changed to remove support for strings.[62]
  • Support was removed for legacy ASP-style delimiters <% and %> and <script language="php"> ... </script>.[63]
  • An oversight allowing a switch statement to have multiple default clauses was fixed.[64]
  • Support for hexadecimal number support in some implicit conversions from strings to number types was removed.[65]
  • The left-shift and right-shift operators were changed to behave more consistently across platforms.[66]
  • Conversions between floating-point numbers and integers were changed (e.g. infinity changed to convert to zero) and implemented more consistently across platforms.[66][67]

PHP 7 also included new language features. Most notably, it introduced return type declarations for functions[68] which complement the existing parameter type declarations, and support for the scalar types (integer, float, string, and boolean) in parameter and return type declarations.[69]

PHP 8.x (2020 onwards)

PHP 8.0 was released on 26 November 2020. PHP 8.0 is a major version and has breaking changes from previous versions.[70][71] New features and notable changes include:

  • Just-in-time compilation[72]. PHP 8's JIT compiler can provide substantial performance improvements for some use cases,[73][74], PHP developer, Nikita Popov stated that the performance improvements for most websites will be less substantial than the upgrade from PHP 5 to PHP 7.[75] Substantial improvements are expected more for mathematical-type operations than for common web-development use cases.[75] Additionally, the JIT compiler provides the future potential to move some code from C to PHP, due to the performance improvements for some use cases.[76]
  • The match expression.[77] The match expression is conceptually similar to a switch statement and is more compact for some use cases.[78] Because match is an expression, its result can be assigned to a variable or returned from a function.[79]
  • union types, a new static return type, and a new mixed type.[70]
  • "Attributes", often referred to as "annotations" in other programming languages, which allow metadata to be added to classes.[70]
  • throw was changed from being a statement to being an expression.[80] This allows exceptions to be thrown in places that were not previously possible.[70]
  • changes to allow alternate, more concise, or more consistent syntaxes in a number of scenarios. For example, the nullsafe operator is similar to the null coalescing operator ??, but used when calling methods.[81]
  • Constructor property promotion as "syntactic sugar," allowing class properties to be set automatically when parameters are passed into a class constructor.[70] This reduces the amount of boilerplate code that must be written.[82]
  • Various adjustments to interfaces, such as adding support for creating DateTime objects from interfaces, and the addition of a Stringable interface that can be used for type hinting.[70]
  • Various new functions including str_contains(), str_starts_with(), and str_ends_with();[83] fdiv(); get_debug_type(); and get_resource_id()[70]
  • Type annotations in PHP's C source code to allow internal functions and methods to have "complete type information in reflection."[84]

PHP 8.1 was released on November 25, 2021.[85] It added support for enumerations (also called "enums"), declaring properties as readonly (which prevents modification of the property after initialization), and array unpacking with string keys. The new never type can be used to indicate that a function does not return.[86]

PHP 8.2 was released on December 8, 2022.[87] New in this release are readonly classes (whose instance properties are implicitly readonly), disjunctive normal form (DNF) types, and the random extension, which provides a pseudorandom number generator with an object-oriented API,[88] Sensitive Parameter value redaction, and a ton of other features.

PHP 8.3 was released on November 23, 2023. This release introduced readonly array properties, allowing arrays to be declared as immutable after initialization.[citation needed] It also added support for class aliases for built-in PHP classes, new methods for random float generation in the Random extension, and enhanced PHP INI settings with fallback value support. Additionally, the new stream_context_set_options function provides improved API for stream manipulation, among other updates and deprecations.

PHP 8.4 was released on November 21, 2024.

Release history