Lably
Skip to content

PHP

Scripting language created in 1994

  • 37 min read
  • 10 chapters

Related on Lably

Through Web server, Interpreter (computing) and HTML

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—can 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. PHP can be used for programming tasks outside the web context, though non-web uses are rare. 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.

History

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

Origins (1993 to 1997)

PHP development began in 1993 when Rasmus Lerdorf wrote several Common Gateway Interface (CGI) programs in C, which he used to maintain his personal homepage. He extended them to work with HTML 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:

<span id="mwqA"></span><span class="cm" id="mwqQ"><!--include /text/header.html--></span> <span class="cm" id="mwqg"><!--getenv HTTP_USER_AGENT--></span> <span class="cm" id="mwqw"><!--if substr $exec_result Mozilla--></span> Hey, you are using Netscape!<span class="p" id="mwrA"><</span><span class="nt" id="mwrQ">p</span><span class="p" id="mwrg">></span> <span class="cm" id="mwrw"><!--endif--></span> <span class="cm" id="mwsA"><!--sql database select * from table where user='$username'--></span> <span class="cm" id="mwsQ"><!--ifless $numentries 1--></span> Sorry, that record does not exist<span class="p" id="mwsg"><</span><span class="nt" id="mwsw">p</span><span class="p" id="mwtA">></span> <span class="cm" id="mwtQ"><!--endif exit--></span> Welcome <span class="cm" id="mwtg"><!--$user--></span>!<span class="p" id="mwtw"><</span><span class="nt" id="mwuA">p</span><span class="p" id="mwuQ">></span> You have <span class="cm" id="mwug"><!--$index:0--></span> credits left in your account.<span class="p" id="mwuw"><</span><span class="nt" id="mwvA">p</span><span class="p" id="mwvQ">></span> <span class="cm" id="mwvg"><!--include /text/footer.html--></span>

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. 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.

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." A development team began to form and, after months of work and beta testing, officially released PHP/FI 2 in November 1997.

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. In some cases, the function names were chosen to match the lower-level libraries which PHP was "wrapping", 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.

PHP 3 and 4 (1998 to 2004)

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. 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. They also founded Zend Technologies in Ramat Gan, Israel.

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

Early PHP 5 (2004 to 2006)

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

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, provided by a consortium of PHP developers promoting the transition from PHP 4 to PHP 5.

PHP 6 and Unicode

PHP's native string functions worked only on raw bytes, making use with multibyte character encodings difficult. 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. 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.

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. 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. Initial hopes were that a new plan would be formed for Unicode integration, but by 2014 none had been adopted.

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, 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). 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, 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.

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

PHP 7.x (2015 to 2019)

During 2014 and 2015, a new major PHP version was developed which became PHP 7.0. The numbering of this version involved some debate among internal developers. 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. After a vote, the name PHP 7 was chosen.

The foundation of PHP 7.0 was a PHP branch that was originally dubbed PHP next generation (phpng). It was written by Dmitry Stogov, Xinchen Hui and Nikita Popov, and aimed to optimize PHP performance by refactoring the Zend Engine while retaining near-complete language compatibility. 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. Because of the significant changes, the reworked Zend Engine was called Zend Engine 3, succeeding Zend Engine 2 used in PHP 5.x.

PHP 7.0 also included changes which were not backward compatible, as allowed for "major versions" under the versioning scheme agreed in 2011. Changes to the core language included a more consistent handling of variable dereferencing, a more predictable behavior of the foreach statement, and platform consistency of bitwise shifts and floating-point to integer conversion. Several unmaintained or deprecated server application programming interfaces (SAPIs) and extensions were removed from the PHP core, most notably the legacy mysql extension. Other legacy features were also removed, such as ASP-style delimiters <% and %> and <script language="php"> ... </script>.

PHP 7.0 marked the beginning of an expansion in PHP's type system. In PHP 5.x, only function parameters could have type declarations, but this was extended to function return types in 7.0., and object properties in 7.4 The types expressible also expanded, with scalar types (integer, float, string, and boolean) in 7.0; iterable type, nullable types, and void return type. all in 7.1; and the object type in 7.2

Other changes in this period aimed to add expressiveness to the language, such as the ?? (null coalesce) and <=> "spaceship" three-way comparison operators in 7.0; new syntax for array derefencing and catching multiple exception types in PHP 7.1; more flexible Heredoc and Nowdoc syntax in 7.3; and the null-coalescing assignment operator in 7.4.

PHP 8.x (2020 onwards)

PHP 8.0 was released on 26 November 2020, as a major version with breaking changes from previous versions.

One of the most high-profile changes was the addition of a JIT compiler, which can provide substantial performance improvements for some use cases. Substantial improvements were expected more for mathematical-type operations than for common web-development use cases. Additionally, the performance advantage of the JIT compiler provides the potential to move some code from C to PHP.

A significant addition to the language in 8.0 is attributes, which allow metadata to be added to program elements such as classes, methods, and parameters. Later versions added built-in attributes which change the behaviour of the language, such as the #[\SensitiveParameter] attribute in PHP 8.2, #[\Override] in PHP 8.3, #[\Deprecated] in PHP 8.4, and the #[\NoDiscard] and #[\DelayedTargetValidation] attributes in PHP 8.5.

A significant extension to the language's type system is the addition of composite types: union types in PHP 8.0 (e.g. int|string meaning "either integer or string"), intersection types in PHP 8.1 (e.g. Traversable&Countable meaning the value must implement both the Traversable and Countable interfaces), and disjunctive normal form (DNF) types in PHP 8.2 (unions of intersections, such as array|(Traversable&Countable)). Additional special type keywords have been added, such as mixed and static in PHP 8.0, never (a bottom type indicating that a function never returns) in PHP 8.1, and null, false, and true as stand-alone types in PHP 8.2.

The addition of a rich type system is part of a general trend towards a stricter language, and PHP 8.0 included breaking changes to the handling of string to number comparisons, numeric strings, and incompatible method signatures. Later versions have introduced deprecation notices for behaviour which is planned as a breaking change in a future major version, such as passing null to non-nullable internal function parameters and referring to properties which have not been declared on the class.

Release summary

Beginning on 28 June 2011, the PHP Development Team implemented a timeline for the release of new versions of PHP. Under this system, at least one release should occur every month. Once per year, a minor release should occur which may include new features. Every minor release should at least be supported for two years with security and bug fixes, followed by at least one year of only security fixes, for a total of a three-year release process for every minor release. No new features, unless small and self-contained, are to be introduced into a minor release during the three-year release process. A 2024 RFC extended the length of the security fix only period to two years, fixed all end of life dates to 31 December, and removed the exception that allowed for "small and self-contained" features to be introduced in patch versions.

Prevalence of outdated versions

W3Techs reports that as of November 2025 (about three years since PHP 7 was discontinued and 23 months after the PHP 8.3 release), unsupported versions such as PHP 7 were still used by well over half of PHP websites, which are outdated and known to be insecure. Those included the 9.7% of PHP websites using the even more outdated (discontinued for 7 years) and insecure PHP 5, released over two decades ago.

Sign in to keep reading

9 more chapters are free with a Lably account.

More in Computing and communication

Source and licence. Adapted from the Wikipedia article “PHP” (this version, 2026-09-28) by its contributors, shared under CC BY-SA 4.0. Lablypedia has left out its tables, references and most pictures, and linked it to other Lablypedia articles.