PHP


PHP is a general-purpose scripting language geared towards web development. It was created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementation is now produced by the PHP Group. PHP was originally an abbreviation of Personal Home Page, but it now stands for the recursive backronym PHP: Hypertext Preprocessor.
PHP code is usually processed on a web server by a PHP interpreter implemented as a module, a daemon or a Common Gateway Interface executable. On a web server, the result of the interpreted and executed PHP codewhich may be any type of data, such as generated HTML or binary image datacan 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 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.

Early history (1993 to 1997)

PHP development began in 1993 when Rasmus Lerdorf wrote several Common Gateway Interface 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:

Hey, you are using Netscape!


Sorry, that record does not exist


Welcome !


You have credits left in your account.



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

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 and 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 extension 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 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" and "major releases". 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 and 5.6.
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 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, 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. 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 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 backwards 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 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 in 7.0; type, nullable types, and return type. all in 7.1; and the type in 7.2
Other changes in this period aimed to add expressiveness to the language, such as the
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 attribute in PHP 8.2, in PHP 8.3, in PHP 8.4, and the and 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, intersection types in PHP 8.1, and disjunctive normal form types in PHP 8.2. Additional special type keywords have been added, such as and in PHP 8.0, in PHP 8.1, and,, and 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.