PHP

PHP
PHP-logo.svg
ParadigmImperative, functional, object-oriented, procedural, reflective
Designed byRasmus Lerdorf
DeveloperZend Technologies
First appeared1995; 23 years ago (1995)[1]
Stable release
7.2.8[2] / July 19, 2018; 2 days ago (2018-07-19)
Preview release
7.3.0 alpha 4[3] / July 19, 2018; 2 days ago (2018-07-19)
Typing discipline

Dynamic, weak

since version 7.0:

Gradual[4]
Implementation languageC (primarily; some components C++)
OSUnix-like, Windows
LicensePHP License (most of Zend engine under Zend Engine License)
Filename extensions.php, .phtml, .php3, .php4, .php5, .php7, .phps, .php-s, .pht
Websitesecure.php.net
Major implementations
Zend Engine, HHVM, Phalanger, Quercus, Parrot
Influenced by
Perl, C, C++, Java, Tcl[1]
Influenced
Falcon, Hack

PHP: Hypertext Preprocessor (or simply PHP) is a server-side scripting language designed for Web development, but also used as a general-purpose programming language. It was originally created by Rasmus Lerdorf in 1994,[5] the PHP reference implementation is now produced by The PHP Group.[6] PHP originally stood for Personal Home Page,[5] but it now stands for the recursive acronym PHP: Hypertext Preprocessor.[7]

PHP code may be embedded into HTML code, or it can be used in combination with various web template systems, web content management systems, and web frameworks. PHP code is usually processed by a PHP interpreter implemented as a module in the web server or as a Common Gateway Interface (CGI) executable. The web server combines the results of the interpreted and executed PHP code, which may be any type of data, including images, with the generated web page. PHP code may also be executed with a command-line interface (CLI) and can be used to implement standalone graphical applications.[8]

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 almost every operating system and platform, free of charge.[9]

The PHP language evolved without a written formal specification or standard until 2014, with the original implementation acting as the de facto standard which other implementations aimed to follow. Since 2014 work has gone on to create a formal PHP specification.[10]

During the 2010s there have been increased efforts towards standardisation and code sharing in PHP applications by projects such as PHP-FIG in the form of PSR initiatives as well as the Packagist repository. PHP hosts a diverse array of web frameworks requiring framework-specific knowledge, with Laravel recently emerging as a popular option by incorporating ideas made popular from other competing non-PHP web frameworks, like Ruby on Rails.

History

Early history

Rasmus Lerdorf, who wrote the original Common Gateway Interface (CGI) component, together with Andi Gutmans and Zeev Suraski, who rewrote the parser that formed PHP 3.

PHP development began in 1994 when Rasmus Lerdorf wrote several Common Gateway Interface (CGI) programs in C,[11][12][13] 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.

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 June 8, 1995.[14][15] This release already had the basic functionality that PHP has today. This included Perl-like variables, form handling, and the ability to embed HTML. The syntax resembled that of Perl, but was simpler, more limited and less consistent.[6]

Early PHP was not intended to be a new programming language, and 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."[16] 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.[17] In some cases, the function names were chosen to match the lower-level libraries which PHP was "wrapping",[18] 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.[19]

PHP 3 and 4

This is an example of custom PHP code for the CMS WordPress.

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.[6][20] 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.[21] They also founded Zend Technologies in Ramat Gan, Israel.[6]

On May 22, 2000, PHP 4, powered by the Zend Engine 1.0, was released.[6] As of August 2008 this branch reached version 4.4.9. PHP 4 is no longer under development nor will any security updates be released.[22][23]

PHP 5

On July 14, 2004, PHP 5 was released, powered by the new Zend Engine II.[6] PHP 5 included new features such as improved support for object-oriented programming, the PHP Data Objects (PDO) extension (which defines a lightweight and consistent interface for accessing databases), and numerous performance enhancements.[24] In 2008 PHP 5 became the only stable version under development. Late static binding had been missing from PHP and was added in version 5.3.[25][26]

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

Over time, PHP interpreters became available on most existing 32-bit and 64-bit operating systems, either by building them from the PHP source code, or by using pre-built binaries.[30] For the PHP versions 5.3 and 5.4, the only available Microsoft Windows binary distributions were 32-bit x86 builds,[31][32] 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.[33]

PHP 6 and Unicode

PHP received mixed reviews due to lacking native Unicode support at the core language level.[34][35] 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.[36] 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.[37]

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.[38] As a result, a PHP 5.3 release was created in 2009, with many non-Unicode features back-ported from PHP 6, notably namespaces. In March 2010, the project in its current form was officially abandoned, and a PHP 5.4 release was prepared containing most remaining non-Unicode features from PHP 6, such as traits and closure re-binding.[39] Initial hopes were that a new plan would be formed for Unicode integration, but as of 2014 none had been adopted.

PHP 7

During 2014 and 2015, a new major PHP version was developed, which was numbered PHP 7. The numbering of this version involved some debate.[40] While the PHP 6 Unicode experiment had never been released, several articles and book titles referenced the PHP 6 name, which might have caused confusion if a new release were to reuse the name.[41] After a vote, the name PHP 7 was chosen.[42]

The foundation of PHP 7 is a PHP branch that was originally dubbed PHP next generation (phpng). It was authored by Dmitry Stogov, Xinchen Hui and Nikita Popov,[43] and aimed to optimize PHP performance by refactoring the Zend Engine while retaining near-complete language compatibility.[44] As of 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 are also expected to make it easier to improve performance in the future, as more compact data structures and other changes are seen as better suited for a successful migration to a just-in-time (JIT) compiler.[45] Because of the significant changes, the reworked Zend Engine is called Zend Engine 3, succeeding Zend Engine 2 used in PHP 5.[46]

Because of 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.[47] 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. In particular, it involved the following changes:

  • Many fatal- or recoverable-level legacy PHP error mechanisms were replaced with modern object-oriented exceptions[48]
  • 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-hand-side expressions[49]
  • Support for legacy PHP 4-style constructor methods was deprecated[50]
  • The behavior of the foreach statement was changed to be more predictable[51]
  • Constructors for the few classes built-in to PHP which returned null upon failure were changed to throw an exception instead, for consistency[52]
  • Several unmaintained or deprecated server application programming interfaces (SAPIs) and extensions were removed from the PHP core, most notably the legacy mysql extension[53]
  • The behavior of the list() operator was changed to remove support for strings[54]
  • Support for legacy ASP-style PHP code delimiters (<% and %>, <script language=php> and </script>) was removed[55]
  • An oversight allowing a switch statement to have multiple default clauses was fixed[56]
  • Support for hexadecimal number support in some implicit conversions from strings to number types was removed[57]
  • The left-shift and right-shift operators were changed to behave more consistently across platforms[58]
  • Conversions between integers and floating point numbers were tightened and implemented more consistently across platforms[58][59]

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

Release history

Key
Color Meaning Development
red Old release No development
yellow Stable release Security fixes
Green Stable release Bug and security fixes
Blue Future release New features
Version Release date Supported until[62] Notes
1.0 8 June 1995 Officially called "Personal Home Page Tools (PHP Tools)". This is the first use of the name "PHP".[6]
2.0 1 November 1997 Officially called "PHP/FI 2.0". This is the first release that could actually be characterised as PHP, being a standalone language with many features that have endured to the present day.
3.0 6 June 1998 20 October 2000[62] Development moves from one person to multiple developers. Zeev Suraski and Andi Gutmans rewrite the base for this version.[6]
4.0 22 May 2000 23 June 2001[62] Added more advanced two-stage parse/execute tag-parsing system called the Zend engine.[63]
4.1 10 December 2001 12 March 2002[62] Introduced "superglobals" ($_GET, $_POST, $_SESSION, etc.)[63]
4.2 22 April 2002 6 September 2002[62] Disabled register_globals by default. Data received over the network is not inserted directly into the global namespace anymore, closing possible security holes in applications.[63]
4.3 27 December 2002 31 March 2005[62] Introduced the command-line interface (CLI), to supplement the CGI.[63][64]
4.4 11 July 2005 7 August 2008[62] Fixed a memory corruption bug, which required breaking binary compatibility with extensions compiled against PHP version 4.3.x.[65]
5.0 13 July 2004 5 September 2005[62] Zend Engine II with a new object model.[66]
5.1 24 November 2005 24 August 2006[62] Performance improvements with introduction of compiler variables in re-engineered PHP Engine.[66] Added PHP Data Objects (PDO) as a consistent interface for accessing databases.[67]
5.2 2 November 2006 6 January 2011[62] Enabled the filter extension by default. Native JSON support.[66]
5.3 30 June 2009 14 August 2014[62] Namespace support; late static bindings, jump label (limited goto), closures, PHP archives (phar), garbage collection for circular references, improved Windows support, sqlite3, mysqlnd as a replacement for libmysql as underlying library for the extensions that work with MySQL, fileinfo as a replacement for mime_magic for better MIME support, the Internationalization extension, and deprecation of ereg extension.
5.4 1 March 2012 3 September 2015[62] Trait support, short array syntax support. Removed items: register_globals, safe_mode, allow_call_time_pass_reference, session_register(), session_unregister() and session_is_registered(). Built-in web server.[68] Several improvements to existing features, performance and reduced memory requirements.
5.5 20 June 2013 10 July 2016[69] Support for generators, finally blocks for exceptions handling, OpCache (based on Zend Optimizer+) bundled in official distribution.[70]
5.6 28 August 2014 31 December 2018[69] Constant scalar expressions, variadic functions, argument unpacking, new exponentiation operator, extensions of the use statement for functions and constants, new phpdbg debugger as a SAPI module, and other smaller improvements.[71]
6.x Not released N/A Abandoned version of PHP that planned to include native Unicode support.[72][73]
7.0 3 December 2015[2] 3 December 2018[47] Zend Engine 3 (performance improvements[45] and 64-bit integer support on Windows[74]), uniform variable syntax,[49] AST-based compilation process,[75] added Closure::call(),[76] bitwise shift consistency across platforms,[77] ?? (null coalesce) operator,[78] Unicode code point escape syntax,[79] return type declarations,[60] scalar type (integer, float, string and boolean) declarations,[61] <=> "spaceship" three-way comparison operator,[80] generator delegation,[81] anonymous classes,[82] simpler and more consistently available CSPRNG API,[83] replacement of many remaining internal PHP "errors" with the more modern exceptions,[48] and shorthand syntax for importing multiple items from a namespace.[84]
7.1 1 December 2016 1 December 2019[69] void return type,[85] class constant visibility modifiers[86]
7.2 30 November 2017 30 November 2020[69] Warning when counting non-countables[87]

Beginning on June 28, 2011, the PHP Group implemented a timeline for the release of new versions of PHP.[47] 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.

Other Languages
Afrikaans: PHP
Alemannisch: PHP
العربية: بي إتش بي
aragonés: PHP
asturianu: PHP
azərbaycanca: PHP
বাংলা: পিএইচপি
Bân-lâm-gú: PHP
беларуская: PHP
беларуская (тарашкевіца)‎: PHP
български: PHP
Boarisch: PHP
bosanski: PHP
brezhoneg: Lavar PHP
català: PHP
Cebuano: PHP
čeština: PHP
Cymraeg: PHP
dansk: PHP
Deutsch: PHP
eesti: PHP
Ελληνικά: PHP
español: PHP
Esperanto: PHP
euskara: PHP
فارسی: پی‌اچ‌پی
français: PHP
galego: PHP
客家語/Hak-kâ-ngî: PHP
한국어: PHP
Հայերեն: PHP
हिन्दी: पीएचपी
hrvatski: PHP
Ido: PHP
Bahasa Indonesia: PHP
interlingua: PHP
íslenska: PHP
italiano: PHP
עברית: PHP
Basa Jawa: PHP
ಕನ್ನಡ: ಪಿ ಎಚ್ ಪಿ
ქართული: PHP
қазақша: PHP
kurdî: PHP
Кыргызча: PHP
Latina: PHP
latviešu: PHP
Lëtzebuergesch: PHP
lietuvių: PHP
lumbaart: PHP
magyar: PHP
македонски: PHP
Malagasy: PHP
മലയാളം: പി.എച്ച്.പി.
मराठी: पीएचपी
Bahasa Melayu: PHP
Mìng-dĕ̤ng-ngṳ̄: PHP
монгол: PHP
မြန်မာဘာသာ: PHP
Nederlands: PHP
नेपाली: पिएचपी
нохчийн: PHP
norsk: PHP
norsk nynorsk: PHP
occitan: PHP
oʻzbekcha/ўзбекча: PHP
ភាសាខ្មែរ: ភីអេចភី
Plattdüütsch: PHP
polski: PHP
português: PHP
română: PHP
русский: PHP
саха тыла: PHP
संस्कृतम्: पी एच् पी
Scots: PHP
shqip: PHP
සිංහල: PHP
Simple English: PHP
slovenščina: PHP
کوردی: پی ئێچ پی
српски / srpski: PHP
srpskohrvatski / српскохрватски: PHP
suomi: PHP
svenska: PHP
Tagalog: PHP
தமிழ்: பி.எச்.பி
Taqbaylit: PHP
тоҷикӣ: PHP
Türkçe: PHP
Türkmençe: PHP
українська: PHP
Tiếng Việt: PHP
Võro: PHP
West-Vlams: PHP
Winaray: PHP
Wolof: PHP
吴语: PHP
ייִדיש: PHP
粵語: PHP
žemaitėška: PHP
中文: PHP
Lingua Franca Nova: PHP