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.[14]
-
W3Techs reports that, as of January 2022, "PHP is used by 78.1% of all the websites whose server-side programming language we know."[15] PHP version 7.4 is the most used version. Support for version 7.3 was dropped on 6 December 2021.
-
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.[1][18] 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.[9]
-
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."[20] 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.[21] In some cases, the function names were chosen to match the lower-level libraries which PHP was "wrapping",[22] 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.[23]
-
On 22 May 2000, PHP 4, powered by the Zend Engine 1.0, was released.[9] 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.[26][27]
-
On 1 July 2004, PHP 5 was released, powered by the new Zend Engine II.[9] 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.[28] In 2008, PHP 5 became the only stable version under development. Late static binding had been missing from previous versions of PHP, and was added in version 5.3.[29][30]
-
Many high-profile open-source projects ceased to support PHP 4 in new code from February 5, 2008, because of the GoPHP5 initiative,[31] provided by a consortium of PHP developers promoting the transition from PHP 4 to PHP 5.[32][33]
-
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.[34] For PHP versions 5.3 and 5.4, the only available Microsoft Windows binary distributions were 32-bit IA-32 builds,[35][36] 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.[37]
-
Official security support for PHP 5.6 ended on 31 December 2018.[38]
-
PHP received mixed reviews due to lacking native Unicode support at the core language level.[39][40] 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.[41] 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.[42]
-
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.[43] 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.[44] Initial hopes were that a new plan would be formed for Unicode integration, but by 2014 none had been adopted.
-
During 2014 and 2015, a new major PHP version was developed, PHP 7. The numbering of this version involved some debate among internal developers.[45] 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.[46] After a vote, the name PHP 7 was chosen.[47]
-
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,[48] and aimed to optimize PHP performance by refactoring the Zend Engine while retaining near-complete language compatibility.[49] 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.[50] Because of the significant changes, the reworked Zend Engine was called Zend Engine 3, succeeding Zend Engine 2 used in PHP 5.[51]
-
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.[52] 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.[53]
-
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.[54]
-
Support for legacy PHP 4-style constructor methods was deprecated.[55]
The behavior of the list() operator was changed to remove support for strings.[59]
-
Support was removed for legacy ASP-style delimiters <% and %> and <script language="php"> ... </script>.[60]
-
An oversight allowing a switch statement to have multiple default clauses was fixed.[61]
-
Support for hexadecimal number support in some implicit conversions from strings to number types was removed.[62]
-
The left-shift and right-shift operators were changed to behave more consistently across platforms.[63]
-
Conversions between floating-point numbers and integers were changed (e.g. infinity changed to convert to zero) and implemented more consistently across platforms.[63][64]
-
PHP 7 also included new language features. Most notably, it introduced return type declarations for functions[65] which complement the existing parameter type declarations, and support for the scalar types (integer, float, string, and boolean) in parameter and return type declarations.[66]
-
PHP 8 was released on November 26, 2020. PHP 8 is a major version and has breaking changes from previous versions.[67][68] New features and notable changes include:
-
PHP 8's JIT compiler can provide substantial performance improvements for some use cases,[70][71] while 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.[72] Substantial improvements are expected more for mathematical-type operations than for common web-development use cases.[72] Additionally, the JIT compiler provides future potential to move some code from C to PHP, due to the performance improvements for some use cases.[73]
-
PHP 8 introduced the match expression.[74] The match expression is conceptually similar to a switch statement and is more compact for some use cases.[75] Because match is an expression, its result can be caught into a variable or returned from a function.[76]
-
PHP 8 introduced union types, a new static return type, and a new mixed type.[67]
-
"Attributes", often referred to as "annotations" in other programming languages, were added in PHP 8, which allow metadata to be added to classes.[67]
-
throw was changed from being a statement to being an expression.[77] This allows exceptions to be thrown in places that were not previously possible.[67]
-
PHP 8 includes 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.[78] The following code snippet will not throw an error if getBirthday() returns null:
-
Constructor property promotion has been added as "syntactic sugar," allowing class properties to be set automatically when parameters are passed into a class constructor.[67] This reduces the amount of boilerplate code that must be written.
-
Other minor changes include support for use of ::class on objects, which serves as an alternative for the use of get_class();[67] non-capturing catches in try-catch blocks; variable syntax tweaks to resolve inconsistencies; support for named arguments; and support for trailing commas in parameter lists, which adds consistency with support for trailing commas in other contexts, such as in arrays.
-
Weak maps were added in PHP 8. A WeakMap holds references to objects, but these references do not prevent such objects from being garbage collected.[79] This can provide performance improvements in scenarios where data is being cached; this is of particular relevance for object relational mappings (ORM).[67]
-
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.
-
Various new functions including str_contains(), str_starts_with(), and str_ends_with();[80] fdiv(); get_debug_type(); and get_resource_id()
Type annotations were also added into PHP's C source code itself to allow internal functions and methods to have "complete type information in reflection."[81]
PHP 8.1 was released on November 25, 2021. It included several improvements, such as enumerations (also called "enums"), readonly properties and array unpacking with string keys.[82]
-
-Support for enumerations was one of the most prominent features of PHP 8.1.[83] Enums allow developers to programmatically enforce states in their codebase. Below is an example of an enum:
Officially called "Personal Home Page Tools (PHP Tools)". This is the first use of the name "PHP".[9]
-
-
-
Old version, no longer maintained: 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.
-
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.[86]
-
Performance improvements with introduction of compiler variables in re-engineered PHP Engine.[94] Added PHP Data Objects (PDO) as a consistent interface for accessing databases.[96]
-
Namespace support; late static bindings, jump label (limited goto), anonymous functions, 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.
-
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.[100] Several improvements to existing features, performance and reduced memory requirements.
-
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.[105]
-
-
-
6.x
-
-
Not released
-
-
N/A
-
-
Abandoned version of PHP that planned to include native Unicode support.[106][107]
-
Zend Engine 3 (performance improvements[50] and 64-bit integer support on Windows[109]), uniform variable syntax,[54]AST-based compilation process,[110] added Closure::call(),[111] bitwise shift consistency across platforms,[112]?? (null coalesce) operator,[113]Unicode code point escape syntax,[114] return type declarations,[65] scalar type (integer, float, string and boolean) declarations,[66]<=> "spaceship" three-way comparison operator,[115]generator delegation,[116]anonymous classes,[117] simpler and more consistently available CSPRNG API,[118] replacement of many remaining internal PHP "errors" with the more modern exceptions,[53] and shorthand syntax for importing multiple items from a namespace.[119]
-
Flexible Heredoc and Nowdoc syntax,[127] support for reference assignment and array deconstruction with list(),[128] PCRE2 support,[129] hrtime() function[130]
-
Just-In-Time (JIT) compilation,[69] arrays starting with a negative index,[144] stricter/saner language semantics (validation for abstract trait methods),[145] saner string to number comparisons,[146] saner numeric strings,[147] TypeError on invalid arithmetic/bitwise operators,[148] reclassification of various engine errors,[149] consistent type errors for internal functions,[150] fatal error for incompatible method signatures[151]), locale-independent float to string conversion,[152] variable syntax tweaks,[153] attributes,[154][155][156][157] named arguments,[158] match expression,[159] constructor property promotion,[160] union types,[161] mixed type,[162] static return type,[163] nullsafe operator,[78] non-capturing catches,[164] throw expression,[77] JSON extension is always available.[165]
-
-
-
Current stable version: 8.1
-
-
25 November 2021
-
-
25 November 2024
-
-
Explicit octal integer literal notation,[166] enumerations,[167] readonly properties,[168] first-class callable syntax,[169] new in initializers,[170] pure intersection types,[171] never return type,[172] final class constraints,[173] fibers[174]
-
-
-
Legend:
Old version
Older version, still maintained
Latest version
Latest preview version
Future release
-
-
Beginning on 28 June 2011, the PHP Development Team implemented a timeline for the release of new versions of PHP.[52] 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.
-
The mascot of the PHP project is the elePHPant, a blue elephant with the PHP logo on its side, designed by Vincent Pontier[175] in 1998.[176] "The (PHP) letters were forming the shape of an elephant if viewed in a sideways angle."[177] The elePHPant is sometimes differently colored when in plush toy form.
-
Many variations of this mascot have been made over the years. Only the elePHPants based on the original design by Vincent Pontier are considered official by the community.[178] These are collectible and some of them are extremely rare.[179]
-
However, as no requirement exists for PHP code to be embedded in HTML, the simplest version of Hello, World! may be written like this, with the closing tag ?> omitted as preferred in files containing pure PHP code.[180]
-
-
<?php
- echo'Hello, World!';
-?>
-
-
The PHP interpreter only executes PHP code within its delimiters. Anything outside of its delimiters is not processed by PHP, although non-PHP text is still subject to control structures described in PHP code. The most common delimiters are <?php to open and ?> to close PHP sections. The shortened form <? also exists. This short delimiter makes script files less portable, since support for them can be disabled in the local PHP configuration and it is therefore discouraged.[181][182] Conversely, there is no recommendation against the echo short tag <?=.[183] Prior to PHP 5.4.0, this short syntax for echo only works with the short_open_tag configuration setting enabled, while for PHP 5.4.0 and later it is always available.[184][185][181] The purpose of all these delimiters is to separate PHP code from non-PHP content, such as JavaScript code or HTML markup.[186] So the shortest "Hello, World!" program written in PHP is:
-
-
<?='Hello, World!';
-
-
The first form of delimiters, <?php and ?>, in XHTML and other XML documents, creates correctly formed XML processing instructions.[187] This means that the resulting mixture of PHP code and other markup in the server-side file is itself well-formed XML.
-
-Variables are prefixed with a dollar symbol, and a type does not need to be specified in advance. PHP 5 introduced type declarations that allows functions to force their parameters to be objects of a specific class, arrays, interfaces or callback functions. However, before PHP 7, type declarations could not be used with scalar types such as integer or string.[66]
-
Below is an example of how PHP variables are declared and initialized.
-
-
<?php
- $name='John';// variable of string type being declared and Initialized
- $age=18;// variable of integer type being declared and Initialized
- $height=5.3;// variable of double type being declared and Initialized
- echo$name.' is '.$height."m tall\n";// concatenating variables and strings
- echo"$name is $age years old.";// interpolating variables to string
-?>
-
-
Unlike function and class names, variable names are case sensitive. Both double-quoted ("") and heredoc strings provide the ability to interpolate a variable's value into the string.[188] PHP treats newlines as whitespace in the manner of a free-form language, and statements are terminated by a semicolon.[189] PHP has three types of comment syntax: /* */ marks block and inline comments; // or # are used for one-line comments.[190] The echo statement is one of several facilities PHP provides to output text.
-
In terms of keywords and language syntax, PHP is similar to the C style syntax. if conditions, for and while loops, and function returns are similar in syntax to languages such as C, C++, C#, Java and Perl.
-
PHP is loosely typed. It stores integers in a platform-dependent range, either as a 32, 64 or 128-bit signedinteger equivalent to the C-language long type. Unsigned integers are converted to signed values in certain situations, which is different behavior to many other programming languages.[191] Integer variables can be assigned using decimal (positive and negative), octal, hexadecimal, and binary notations.
-
Floating point numbers are also stored in a platform-specific range. They can be specified using floating point notation, or two forms of scientific notation.[192] PHP has a native Boolean type that is similar to the native Boolean types in Java and C++. Using the Boolean type conversion rules, non-zero values are interpreted as true and zero as false, as in Perl and C++.[192]
-
The null data type represents a variable that has no value; NULL is the only allowed value for this data type.[192]
-
Variables of the "resource" type represent references to resources from external sources. These are typically created by functions from a particular extension, and can only be processed by functions from the same extension; examples include file, image, and database resources.[192]
-
Arrays can contain elements of any type that PHP can handle, including resources, objects, and even other arrays. Order is preserved in lists of values and in hashes with both keys and values, and the two can be intermingled.[192] PHP also supports strings, which can be used with single quotes, double quotes, nowdoc or heredoc syntax.[193]
-
The Standard PHP Library (SPL) attempts to solve standard problems and implements efficient data access interfaces and classes.[194]
-
PHP defines a large array of functions in the core language and many are also available in various extensions; these functions are well documented in the online PHP documentation.[195] However, the built-in library has a wide variety of naming conventions and associated inconsistencies, as described under history above.
-
Custom functions may be defined by the developer:
-
-
functionmyAge(int$birthYear):string
-{
- // calculate the age by subtracting the birth year from the current year.
- $yearsOld=date('Y')-$birthYear;
-
- // return the age in a descriptive string.
- return$yearsOld.' year'.($yearsOld!=1?'s':'');
-}
-
-echo'I am currently '.myAge(1995).' old.';
-
-
In 2022, the output of the above sample program is 'I am currently 27 years old.'
-
In lieu of function pointers, functions in PHP can be referenced by a string containing their name. In this manner, normal PHP functions can be used, for example, as callbacks or within function tables.[196] User-defined functions may be created at any time without being prototyped.[195][196] Functions may be defined inside code blocks, permitting a run-time decision as to whether or not a function should be defined. There is a function_exists function that determines whether a function with a given name has already been defined. Function calls must use parentheses, with the exception of zero-argument class constructor functions called with the PHP operator new, in which case parentheses are optional.
-
Until PHP 5.3, support for anonymous functions and closures did not exist in PHP. While create_function() has existed since PHP 4.0.1, it is merely a thin wrapper around eval() that allows normal PHP functions to be created during program execution.[197] PHP 5.3 added syntax to define an anonymous function or "closure"[198] which can capture variables from the surrounding scope. Shorthand arrow syntax was added in PHP 7.4:[199]
-
-
functiongetAdder($x){
- returnfn($y)=>$x+$y;
-}
-
-$adder=getAdder(8);
-echo$adder(2);// prints "10"
-
-
In the example above, getAdder() function creates a closure using passed argument $x (the keyword use imports a variable from the lexical context), which takes an additional argument $y, and returns the created closure to the caller. Such a function is a first-class object, meaning that it can be stored in a variable, passed as a parameter to other functions, etc.[200]
-
Unusually for a dynamically typed language, PHP supports type declarations on function parameters, which are enforced at runtime. This has been supported for classes and interfaces since PHP 5.0, for arrays since PHP 5.1, for "callables" since PHP 5.4, and scalar (integer, float, string and boolean) types since PHP 7.0.[66] PHP 7.0 also has type declarations for function return types, expressed by placing the type name after the list of parameters, preceded by a colon.[65] For example, the getAdder function from the earlier example could be annotated with types like so in PHP 7:
-
-
functiongetAdder(int$x):Closure
-{
- returnfn(int$y):int=>$x+$y;
-}
-
-$adder=getAdder(8);
-echo$adder(2);// prints "10"
-echo$adder(null);// throws an exception because an incorrect type was passed
-$adder=getAdder([]);// would also throw an exception
-
-
By default, scalar type declarations follow weak typing principles. So, for example, if a parameter's type is int, PHP would allow not only integers, but also convertible numeric strings, floats or booleans to be passed to that function, and would convert them.[66] However, PHP 7 has a "strict typing" mode which, when used, disallows such conversions for function calls and returns within a file.[66]
-
Basic object-oriented programming functionality was added in PHP 3 and improved in PHP 4.[9] This allowed for PHP to gain further abstraction, making creative tasks easier for programmers using the language. Object handling was completely rewritten for PHP 5, expanding the feature set and enhancing performance.[201] In previous versions of PHP, objects were handled like value types.[201] The drawback of this method was that code had to make heavy use of PHP's "reference" variables if it wanted to modify an object it was passed rather than creating a copy of it. In the new approach, objects are referenced by handle, and not by value.
-
If the developer creates a copy of an object using the reserved word clone, the Zend engine will check whether a __clone() method has been defined. If not, it will call a default __clone() which will copy the object's properties. If a __clone() method is defined, then it will be responsible for setting the necessary properties in the created object. For convenience, the engine will supply a function that imports the properties of the source object, so the programmer can start with a by-value replica of the source object and only override properties that need to be changed.[203]
-
The visibility of PHP properties and methods is defined using the keywordspublic, private, and protected. The default is public, if only var is used; var is a synonym for public. Items declared public can be accessed everywhere. protected limits access to inherited classes (and to the class that defines the item). private limits visibility only to the class that defines the item.[204] Objects of the same type have access to each other's private and protected members even though they are not the same instance.
-
The only complete PHP implementation is the original, known simply as PHP. It is the most widely used and is powered by the Zend Engine. To disambiguate it from other implementations, it is sometimes unofficially called "Zend PHP". The Zend Engine compiles PHP source code on-the-fly into an internal format that it can execute, thus it works as an interpreter.[205][206] It is also the "reference implementation" of PHP, as PHP has no formal specification, and so the semantics of Zend PHP define the semantics of PHP. Due to the complex and nuanced semantics of PHP, defined by how Zend works, it is difficult for competing implementations to offer complete compatibility.
-
PHP's single-request-per-script-execution model, and the fact that the Zend Engine is an interpreter, leads to inefficiency; as a result, various products have been developed to help improve PHP performance. In order to speed up execution time and not have to compile the PHP source code every time the web page is accessed, PHP scripts can also be deployed in the PHP engine's internal format by using an opcode cache, which works by caching the compiled form of a PHP script (opcodes) in shared memory to avoid the overhead of parsing and compiling the code every time the script runs. An opcode cache, Zend Opcache, is built into PHP since version 5.5.[207] Another example of a widely used opcode cache is the Alternative PHP Cache (APC), which is available as a PECL extension.[208]
-
While Zend PHP is still the most popular implementation, several other implementations have been developed. Some of these are compilers or support JIT compilation, and hence offer performance benefits over Zend PHP at the expense of lacking full PHP compatibility. Alternative implementations include the following:
-
-
HHVM (HipHop Virtual Machine) – developed at Facebook and available as open source, it converts PHP code into a high-level bytecode (commonly known as an intermediate language), which is then translated into x86-64 machine code dynamically at runtime by a just-in-time (JIT) compiler, resulting in up to 6× performance improvements.[209] However, since version 7.2 Zend has outperformed HHVM,[210] and HHVM 3.24 is the last version to officially support PHP.[211]
-
Parrot – a virtual machine designed to run dynamic languages efficiently; Pipp transforms the PHP source code into the Parrot intermediate representation, which is then translated into the Parrot's bytecode and executed by the virtual machine.
-
PeachPie – a second-generation compiler to .NETCommon Intermediate Language (CIL) bytecode, built on the Roslyn platform; successor of Phalanger, sharing several architectural components
-
Phalanger – compiles PHP into .Net Common Intermediate Language bytecode; predecessor of PeachPie
HipHop – developed at Facebook and available as open source, it transforms the PHP scripts into C++ code and then compiles the resulting code, reducing the server load up to 50%. In early 2013, Facebook deprecated it in favor of HHVM due to multiple reasons, including deployment difficulties and lack of support for the whole PHP language, including the create_function() and eval() constructs.[212]
Products derived from this software may not be called "PHP", nor may "PHP" appear in their name, without prior written permission from group@php.net. You may indicate that your software works in conjunction with PHP by saying "Foo for PHP" instead of calling it "PHP Foo" or "phpfoo".
-
-
This restriction on use of "PHP" makes the PHP License incompatible with the General Public License (GPL), while the Zend License is incompatible due to an advertising clause similar to that of the original BSD license.[214]
-
PHP includes various free and open-source libraries in its source distribution, or uses them in resulting PHP binary builds. PHP is fundamentally an Internet-aware system with built-in modules for accessing File Transfer Protocol (FTP) servers and many database servers, including PostgreSQL, MySQL, Microsoft SQL Server and SQLite (which is an embedded database), LDAP servers, and others. Numerous functions familiar to C programmers, such as those in the stdio family, are available in standard PHP builds.[215]
-
PHP allows developers to write extensions in C to add functionality to the PHP language. PHP extensions can be compiled statically into PHP or loaded dynamically at runtime. Numerous extensions have been written to add support for the Windows API, process management on Unix-likeoperating systems, multibyte strings (Unicode), cURL, and several popular compression formats. Other PHP features made available through extensions include integration with Internet Relay Chat (IRC), dynamic generation of images and Adobe Flash content, PHP Data Objects (PDO) as an abstraction layer used for accessing databases,[216][217][218][219][220][221][222] and even speech synthesis. Some of the language's core functions, such as those dealing with strings and arrays, are also implemented as extensions.[223] The PHP Extension Community Library (PECL) project is a repository for extensions to the PHP language.[224]
-
Some other projects, such as Zephir, provide the ability for PHP extensions to be created in a high-level language and compiled into native PHP extensions. Such an approach, instead of writing PHP extensions directly in C, simplifies the development of extensions and reduces the time required for programming and testing.[225]
-
Zend Technologies provides a PHP Certification based on PHP 7[227] exam (and previously based on PHP 5.5) for programmers to become certified PHP developers.
-
PHP-FPM (FastCGI Process Manager) is an alternative FastCGI implementation for PHP, bundled with the official PHP distribution since version 5.3.3.[229] When compared to the older FastCGI implementation, it contains some additional features, mostly useful for heavily loaded web servers.[230]
-
When using PHP for command-line scripting, a PHP command-line interface (CLI) executable is needed. PHP supports a CLI server application programming interface (SAPI) since PHP 4.3.0.[231] The main focus of this SAPI is developing shell applications using PHP. There are quite a few differences between the CLI SAPI and other SAPIs, although they do share many of the same behaviors.[232]
-
PHP has a direct module interface called SAPI for different web servers;[233] in case of PHP 5 and Apache 2.0 on Windows, it is provided in form of a DLL file called php5apache2.dll,[234] which is a module that, among other functions, provides an interface between PHP and the web server, implemented in a form that the server understands. This form is what is known as a SAPI.
-
There are different kinds of SAPIs for various web server extensions. For example, in addition to those listed above, other SAPIs for the PHP language include the Common Gateway Interface and command-line interface.[233][235]
-
PHP can also be used for writing desktop graphical user interface (GUI) applications, by using the PHP-GTK extension. PHP-GTK is not included in the official PHP distribution,[228] and as an extension it can be used only with PHP versions 5.1.0 and newer. The most common way of installing PHP-GTK is compiling it from the source code.[236]
-
When PHP is installed and used in cloud environments, software development kits (SDKs) are provided for using cloud-specific features. For example:
-
Numerous configuration options are supported, affecting both core PHP features and extensions.[239][240] Configuration file php.ini is searched for in different locations, depending on the way PHP is used.[241] The configuration file is split into various sections,[242] while some of the configuration options can be also set within the web server configuration.[243]
-
A broad overview of the LAMP software bundle, displayed here together with Squid
-
PHP is a general-purpose scripting language that is especially suited to server-sideweb development, in which case PHP generally runs on a web server. Any PHP code in a requested file is executed by the PHP runtime, usually to create dynamic web page content or dynamic images used on websites or elsewhere.[244] It can also be used for command-line scripting and client-sidegraphical user interface (GUI) applications. PHP can be deployed on most web servers, many operating systems and platforms, and can be used with many relational database management systems (RDBMS). Most web hosting providers support PHP for use by their clients. It is available free of charge, and the PHP Group provides the complete source code for users to build, customize and extend for their own use.[13]
-
The LAMP architecture has become popular in the web industry as a way of deploying web applications.[247] PHP is commonly used as the P in this bundle alongside Linux, Apache and MySQL, although the P may also refer to Python, Perl, or some mix of the three. Similar packages, WAMP and MAMP, are also available for Windows and macOS, with the first letter standing for the respective operating system. Although both PHP and Apache are provided as part of the macOS base install, users of these packages seek a simpler installation mechanism that can be more easily kept up to date.
-
For specific and more advanced usage scenarios, PHP offers a well defined and documented way for writing custom extensions in C or C++.[248][249][250][251][252][253][254] Besides extending the language itself in form of additional libraries, extensions are providing a way for improving execution speed where it is critical and there is room for improvements by using a true compiled language.[255][256] PHP also offers well defined ways for embedding itself into other software projects. That way PHP can be easily used as an internal scripting language for another project, also providing tight interfacing with the project's specific internal data structures.[257]
-
PHP received mixed reviews due to lacking support for multithreading at the core language level,[258] though using threads is made possible by the "pthreads" PECL extension.[259][260]
-
A command line interface, php-cli, and two ActiveXWindows Script Host scripting engines for PHP have been produced.
-
As of January 2013, PHP was used in more than 240 million websites (39% of those sampled) and was installed on 2.1 million web servers.[271]
-
As of March 2021, PHP was used as the server-side programming language on 79.1% of websites, down from 83.5% previously, where the language could be determined, and PHP 7 is the most used version of the language with 50.3% of all websites on the web are using that version.[272]
-
In 2019, 11% of all vulnerabilities listed by the National Vulnerability Database were linked to PHP;[273] historically, about 30% of all vulnerabilities listed since 1996 in this database are linked to PHP. Technical security flaws of the language itself or of its core libraries are not frequent (22 in 2009, about 1% of the total although PHP applies to about 20% of programs listed).[274] Recognizing that programmers make mistakes, some languages include taint checking to automatically detect the lack of input validation which induces many issues. Such a feature is being developed for PHP,[275] but its inclusion into a release has been rejected several times in the past.[276][277]
-
There are advanced protection patches such as Suhosin and Hardening-Patch, especially designed for web hosting environments.[278]
-
Historically, old versions of PHP had some configuration parameters and default values for such runtime settings that made some PHP applications prone to security issues. Among these, magic_quotes_gpc and register_globals[279] configuration directives were the best known; the latter made any URL parameters become PHP variables, opening a path for serious security vulnerabilities by allowing an attacker to set the value of any uninitialized global variable and interfere with the execution of a PHP script. Support for "magic quotes" and "register globals" settings has been deprecated since PHP 5.3.0, and removed from PHP 5.4.0.[280]
-
Another example for the potential runtime-settings vulnerability comes from failing to disable PHP execution (for example by using the engine configuration directive)[281] for the directory where uploaded files are stored; enabling it can result in execution of malicious code embedded within the uploaded files.[282][283][284] The best practice is to either locate the image directory outside of the document root available to the web server and serve it via intermediary script, or disable PHP execution for the directory which stores the uploaded files.
-
Also, enabling the dynamic loading of PHP extensions (via enable_dl configuration directive)[285] in a shared web hosting environment can lead to security issues.[286][287]
-
Implied type conversions that result in different values being treated as equal, sometimes against the programmer's intent, can lead to security issues. For example, the result of the comparison '0e1234' == '0' is true, because strings that are parsable as numbers are converted to numbers; in this case, the first compared value is treated as scientific notation having the value (0×101234), which is zero. Errors like this resulted in authentication vulnerabilities in Simple Machines Forum,[288]Typo3[289] and phpBB[290] when MD5password hashes were compared. The recommended way is to use hash_equals() (for timing attack safety), strcmp or the identity operator (===), as '0e1234' === '0' results in false.[291]
-
In a 2013 analysis of over 170,000 website defacements, published by Zone-H, the most frequently (53%) used technique was exploitation of file inclusion vulnerability, mostly related to insecure usage of the PHP language constructs include, require, and allow_url_fopen.[292][293]
-
As of April 2021, W3Techs reports that 64%
-of websites using PHP, use versions 7.2 or older (which are no longer supported by The PHP Development Team) with 35%
-of all PHP websites using version 5.6 or older.[294]
-
Version 5 is still used by 24.5% of all the websites (September 2021).[295] It is highly recommended to migrate to PHP version 7 or 8 and use random_int() instead of rand() or mt_rand(). There are two attacks that can be performed over PHP entropy sources: "Seed Attack" and "State recovery attack". With current GPU technologies an attacker can perform up to 2^30 MD5 calculations per second with a $250 GPU, while with an additional $500 can reach up to 2^32 calculations.[296] In combination with a "birthday attack" this can lead to a serious security vulnerabilities.
-
^ Jump up to: ab"PHP RFC: Integer Semantics". php.net. Retrieved 2015-05-21. Making NaN and Infinity always become zero when cast to integer means more cross-platform consistency, and is also less surprising than what is currently produces
-
^"Resetting PHP 6". There have been books on the shelves purporting to cover PHP 6 since at least 2008. But, in March 2010, the PHP 6 release is not out – in fact, it is not even close to out. Recent events suggest that PHP 6 will not be released before 2011 – if, indeed, it is released at all.
-
-
^"PHP 7 moves full speed ahead". 2014-10-31. Recent versions of PHP have been part of the 5.x release series, but there will be no PHP 6. "We're going to skip [version] 6, because years ago, we had plans for a 6, but those plans were very different from what we're doing now," Gutmans said. Going right to version 7 avoids confusion.
-
My dad emigrated from Colombia to North America when he was 18 looking looking for a better life. For my brother and I that meant a lot of standing outside in the cold. My dad’s preferred method of improving his lot was improving lots, and my brother and I were “voluntarily” recruited to help working on the buildings we owned.
+
That’s how I came to spend a substantial part of my teenage years replacing fences, digging trenches, and building flooring and sheds. And if there’s one thing I’ve learned from all this building, it’s that reality has a surprising amount of detail.
+
This turns out to explain why its so easy for people to end up intellectually stuck. Even when they’re literally the best in the world in their field.
+
Consider building some basement stairs for a moment. Stairs seem pretty simple at first, and at a high level they are simple, just two long, wide parallel boards (2” x 12” x 16’), some boards for the stairs and an angle bracket on each side to hold up each stair. But as you actually start building you’ll find there’s a surprising amount of nuance.
+
The first thing you’ll notice is that there are actually quite a few subtasks. Even at a high level, you have to cut both ends of the 2x12s at the correct angles; then screw in some u-brackets to the main floor to hold the stairs in place; then screw in the 2x12s into the u-brackets; then attach the angle brackets for the stairs; then screw in the stairs.
+
+
Those goddamn stairs.
+
+
+
Next you’ll notice that each of those steps above decomposes into several steps, some of which have some tricky details to them due to the properties of the materials and task and the limitations of yourself and your tools.
+
The first problem you’ll encounter is that cutting your 2x12s to the right angle is a bit complicated because there’s no obvious way to trace the correct angles. You can either get creative (there is a way to trace it), or you can bust out your trig book and figure out how to calculate the angle and position of the cuts.
+
You’ll probably also want to look up what are reasonable angles for stairs. What looks reasonable when you’re cutting and what feels safe can be different. Also, you’re probably going to want to attach a guide for your circular saw when cutting the angle on the 2x12s because the cut has to be pretty straight.
+
When you’re ready to you will quickly find that getting the stair boards at all the same angle is non-trivial. You’re going to need something that can give you an angle to the main board very consistently. Once you have that, and you’ve drawn your lines, you may be dismayed to discover that your straight looking board is not that straight. Lumber warps after it’s made because it was cut when it was new and wet and now it’s dryer, so no lumber is perfectly straight.
+
Once you’ve gone back to the lumber store and gotten some straighter 2x12s and redrawn your lines, you can start screwing in your brackets. Now you’ll learn that despite starting aligned with the lines you drew, after screwing them in, your angle brackets are no longer quite straight because the screws didn’t go in quite straight and now they tightly secure the bracket at the wrong angle. You can fix that by drilling guide holes first. Also you’ll have to move them an inch or so because it’s more or less impossible to get a screw to go in differently than it did the first time in the same hole.
+
Now you’re finally ready to screw in the stair boards. If your screws are longer than 2”, you’ll need different ones, otherwise they will poke out the top of the board and stab you in the foot.
+
At every step and every level there’s an abundance of detail with material consequences.
+
It’s tempting to think ‘So what?’ and dismiss these details as incidental or specific to stair carpentry. And they are specific to stair carpentry; that’s what makes them details. But the existence of a surprising number of meaningful details is not specific to stairs. Surprising detail is a near universal property of getting up close and personal with reality.
+
You can see this everywhere if you look. For example, you’ve probably had the experience of doing something for the first time, maybe growing vegetables or using a Haskell package for the first time, and being frustrated by how many annoying snags there were. Then you got more practice and then you told yourself ‘man, it was so simple all along, I don’t know why I had so much trouble’. We run into a fundamental property of the universe and mistake it for a personal failing.
+
If you’re a programmer, you might think that the fiddliness of programming is a special feature of programming, but really it’s that everything is fiddly, but you only notice the fiddliness when you’re new, and in programming you do new things more often.
+
You might think the fiddly detailiness of things is limited to human centric domains, and that physics itself is simple and elegant. That’s true in some sense – the physical laws themselves tend to be quite simple – but the manifestation of those laws is often complex and counterintuitive.
+
II. Boiling A Watched Pot
+
Consider the boiling of water. That’s straightforward, water boils at 100 °C, right?
+
Well the stairs seemed simple too, so let’s double check.
+
Put yourself in the shoes of someone at the start of the 1800’s, with only a crude, unmarked mercury thermometer, trying to figure the physics of temperature.
+
Go to your stove, put some water in a pot, start heating some water, and pay attention as it heats.
+
(I suggest actually doing this)
+
The first thing you’ll probably notice is a lot of small bubbles gathering on the surface of the pot. Is that boiling? The water’s not that hot yet; you can still even stick your finger in. Then the bubbles will appear faster and start rising, but they somehow seem ‘unboiling’. Then you’ll start to see little bubble storms in patches, and you start to hear a hissing noise. Is that Boiling? Sort of? It doesn’t really look like boiling. The bubble storms grow larger and start releasing bigger bubbles. Eventually the bubbles get big and the surface of the water grows turbulent as the bubbles begin to make it to the surface. Finally we seem to have reached real boiling. I guess this is the boiling point? That seems kind of weird, what were the things that happened earlier if not boiling.
+
To make matters worse, if you’d used a glass pot instead of a metal one, the water would boil at a higher temperature. If you cleaned the glass vessel with sulfuric acid, to remove any residue, you’d find that you can heat water substantially more before it boils and when it does boil it boils in little explosions of boiling and the temperature fluctuates unstably.
+
Worse still, if you trap a drop of water between two other liquids and heat it, you can raise the temperature to at least 300 °C with nothing happening. That kind of makes a mockery of the statement ‘water boils at 100 °C’.
+
It turns out that ‘boiling’ is a lot more complicated than you thought.
+
This surprising amount of detail is is not limited to “human” or “complicated” domains, it is a near universal property of everything from space travel to sewing, to your internal experience of your own mind.
+
III. Invisible vs. Transparent Detail And Getting Intellectually Stuck
+
Again, you might think ‘So what? I guess things are complicated but I can just notice the details as I run into them; no need to think specifically about this’. And if you are doing things that are relatively simple, things that humanity has been doing for a long time, this is often true. But if you’re trying to do difficult things, things which are not known to be possible, it is not true.
+
The more difficult your mission, the more details there will be that are critical to understand for success.
+
You might hope that these surprising details are irrelevant to your mission, but not so. Some of them will end up being key. Wood’s tendency to warp means it’s more accurate to trace a cut than to calculate its length and angle. The possibility of superheating liquids means it’s important to use a packed bed when boiling liquids in industrial processes lest your process be highly inefficient and unpredictable. The massive difference in weight between a rocket full of fuel and an empty one means that a reusable rocket can’t hover if it can’t throttle down to a very small fraction of its original thrust, which in turn means it must plan its trajectory very precisely to achieve 0 velocity at exactly the moment it reaches the ground.
+
+
Some important details for colonizing the universe.
+
+
+
You might also hope that the important details will be obvious when you run into them, but not so. Such details aren’t automatically visible, even when you’re directly running up against them. Things can just seem messy and noisy instead. ‘Spirit’ thermometers, made using brandy and other liquors, were in common use in the early days of thermometry. They were even considered as a potential standard fluid for thermometers. It wasn’t until the careful work of Swiss physicist Jean-André De Luc in the 18th century that physicists realized that alcohol thermometers are highly nonlinear and highly variable depending on concentration, which is in turn hard to measure.
+
You’ve probably also had experiences where you were trying to do something and growing increasingly frustrated because it wasn’t working, and then finally, after some time you realize that your solution method can’t possibly work.
+
Another way to see that noticing the right details is hard, is that different people end up noticing different details. My brother and I once built a set of stairs for the garage with my dad, and we ran into the problem of determining where to cut the long boards so they lie at the correct angle. After struggling with the problem for a while (and I do mean struggling, a 16’ long board is heavy), we got to arguing. I remembered from trig that we could figure out angle so I wanted to go dig up my textbook and think about it. My dad said, ‘no, no, no, let’s just trace it’, insisting that we could figure out how to do it.
+
I kept arguing because I thought I was right. I felt really annoyed with him and he was annoyed with me. In retrospect, I think I saw the fundamental difficulty in what we were doing and I don’t think he appreciated it (look at the stairs picture and see if you can figure it out), he just heard ‘let’s draw some diagrams and compute the angle’ and didn’t think that was the solution, and if he had appreciated the thing that I saw I think he would have been more open to drawing some diagrams. But at the same time, he also understood that diagrams and math don’t account for the shape of the wood, which I did not appreciate. If we had been able to get these points across, we could have come to consensus. Drawing a diagram was probably a good idea, but computing the angle was probably not. Instead we stayed annoyed at each other for the next 3 hours.
+
Before you’ve noticed important details they are, of course, basically invisible. It’s hard to put your attention on them because you don’t even know what you’re looking for. But after you see them they quickly become so integrated into your intuitive models of the world that they become essentially transparent. Do you remember the insights that were crucial in learning to ride a bike or drive? How about the details and insights you have that led you to be good at the things you’re good at?
+
This means it’s really easy to get stuck. Stuck in your current way of seeing and thinking about things. Frames are made out of the details that seem important to you. The important details you haven’t noticed are invisible to you, and the details you have noticed seem completely obvious and you see right through them. This all makes makes it difficult to imagine how you could be missing something important.
+
That’s why if you ask an anti-climate change person (or a climate scientist) “what could convince you you were wrong?” you’ll likely get back an answer like “if it turned out all the data on my side was faked” or some other extremely strong requirement for evidence rather than “I would start doubting if I noticed numerous important mistakes in the details my side’s data and my colleagues didn’t want to talk about it”. The second case is much more likely than the first, but you’ll never see it if you’re not paying close attention.
+
If you’re trying to do impossible things, this effect should chill you to your bones. It means you could be intellectually stuck right at this very moment, with the evidence right in front of your face and you just can’t see it.
+
This problem is not easy to fix, but it’s not impossible either. I’ve mostly fixed it for myself. The direction for improvement is clear: seek detail you would not normally notice about the world. When you go for a walk, notice the unexpected detail in a flower or what the seams in the road imply about how the road was built. When you talk to someone who is smart but just seems so wrong, figure out what details seem important to them and why. In your work, notice how that meeting actually wouldn’t have accomplished much if Sarah hadn’t pointed out that one thing. As you learn, notice which details actually change how you think.
+
If you wish to not get stuck, seek to perceive what you have not yet perceived.