{
  "id": "enwiki-001377202799",
  "slug": "php",
  "title": "PHP",
  "qid": "",
  "lead": "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 (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.",
  "body": "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 (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. 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 (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 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&nbsp;5.3 release was created in 2009, and in March 2010, the project in its current form was officially abandoned, and a PHP&nbsp;5.4 release was prepared to contain most remaining non-Unicode features from PHP&nbsp;6. Initial hopes were that a new plan would be formed for Unicode integration, but by 2014 none had been adopted. 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 &lt;% and %&gt; and &lt;script language=\"php\"&gt; ... &lt;/script&gt; . 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; 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 (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. == Mascot == The mascot of the PHP project is the elePHPant, a blue elephant with the PHP logo on its side, designed by Vincent Pontier in 1998. \"The (PHP) letters were forming the shape of an elephant if viewed in a sideways angle.\" The elePHPant is sometimes differently coloured when in plush toy form. Many variations of this physical mascot have been made over the years. Only the elePHPants based on the original design by Vincent Pontier are considered official by the community. These are collectable and some of them are extremely rare. PHP \"Hello, World!\" program The PHP interpreter only executes PHP code within its delimiters. Anything outside its delimiters is not processed by PHP, although the non-PHP text can still be subject to control structures described in PHP code. is used to open and ?> to close PHP sections. A shorthand exists, which is a shorthand for . The shortened form also exists, which makes script files less portable since support can be disabled in the local PHP configuration. The shortened form is discouraged by the PHP Group for this reason. Conversely, there is no recommendation against the echo short tag . Prior to PHP&nbsp;5.4.0, the short syntax for echo only works with the short_open_tag configuration setting enabled, while for PHP&nbsp;5.4.0 and later it is always available. The purpose of delimiters is to separate PHP code from non-PHP content, such as JavaScript code or HTML markup. The first form of delimiters, and ?> , in XHTML and other XML documents, creates correctly formed XML processing instructions. 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&nbsp;5 introduced type declarations that allow functions to force their parameters to be objects of a specific class, arrays, interfaces or callback functions. However, before PHP&nbsp;7, type declarations could not be used with scalar types such as integers or strings. Below is an example of how PHP variables are declared and initialized. 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. PHP treats newlines as whitespace in the manner of a free-form language, and statements are terminated by a semicolon. PHP has three types of comments: /* */ marks block and inline comments; // or # are used for one-line comments. The echo statement is one of several keywords PHP provides to output text. In terms of keywords and language syntax, PHP is similar to 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. function myAge(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 . ($yearsOld == 1 ? ' year' : ' years'); } echo 'I am currently ' . myAge(1995) . ' old.'; As of , the output of the above sample program is \"I am currently 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. User-defined functions may be created at any time without being prototyped. 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. Since PHP&nbsp;4.0.1 create_function() , a thin wrapper around eval() , allowed normal PHP functions to be created during program execution; it was deprecated in PHP&nbsp;7.2 and removed in PHP&nbsp;8.0 in favor of syntax for anonymous functions or \"closures\" that can capture variables from the surrounding scope, which was added in PHP&nbsp;5.3. Shorthand arrow syntax was added in PHP&nbsp;7.4: function getAdder($x) { return fn($y) => $x + $y; } $adder = getAdder(8); echo $adder(2); // prints \"10\" In the example above, getAdder() function creates a closure using passed argument , which takes an additional argument , 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. 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&nbsp;5.0, for arrays since PHP&nbsp;5.1, for \"callables\" since PHP&nbsp;5.4, and scalar (integer, float, string and boolean) types since PHP&nbsp;7.0. PHP&nbsp;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. For example, the getAdder function from the earlier example could be annotated with types like so in PHP&nbsp;7: function getAdder(int $x): Closure { return fn(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. However, PHP&nbsp;7 has a \"strict typing\" mode which, when used, disallows such conversions for function calls and returns within a file. name = ucfirst(strtolower($name)); } public function greet(): string { return \"Hello, my name is \" . $this->name; } abstract public function job(): string; } class Student extends User { public function __construct(string $name, private string $course) { parent::__construct($name); } public function job(): string { return \"I learn \" . $this->course; } } class Teacher extends User { public function __construct(string $name, private array $teachingCourses) { parent::__construct($name); } public function job(): string { return \"I teach \" . implode(\", \", $this->teachingCourses); } } $students = [ new Student(\"Alice\", \"Computer Science\"), new Student(\"Bob\", \"Computer Science\"), new Student(\"Charlie\", \"Business Studies\"), ]; $teachers = [ new Teacher(\"Dan\", [\"Computer Science\", \"Information Security\"]), new Teacher(\"Erin\", [\"Computer Science\", \"3D Graphics Programming\"]), new Teacher(\"Frankie\", [\"Online Marketing\", \"Business Studies\", \"E-commerce\"]), ]; foreach ([$students, $teachers] as $users) { echo $users[0]::class . \"s:\\n\"; array_walk($users, function (User $user) { echo \"{$user->greet()}, {$user->job()}\\n\"; }); } This program outputs the following: == Installation and configuration == There are two primary ways for adding support for PHP to a web server&nbsp;– as a native web server module, or as a CGI executable. PHP has a direct module interface called server application programming interface (SAPI), which is supported by many web servers including Apache HTTP Server, Microsoft IIS, Caddy (through FrankenPHP) and iPlanet Web Server. Some other web servers, such as OmniHTTPd, support the Internet Server Application Programming Interface (ISAPI), which is Microsoft's web server module interface. If PHP has no module support for a web server, it can always be used as a Common Gateway Interface (CGI) or FastCGI processor; in that case, the web server is configured to use PHP's CGI executable to process all requests to PHP files. PHP-FPM (FastCGI Process Manager) is an alternative FastCGI implementation for PHP, bundled with the official PHP distribution since version 5.3.3. When compared to the older FastCGI implementation, it contains some additional features, mostly useful for heavily loaded web servers. 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&nbsp;4.3.0. 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 behaviours. PHP has a direct module interface called SAPI for different web servers; in case of PHP&nbsp;5 and Apache&nbsp;2.0 on Windows, it is provided in form of a DLL file called , 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. PHP can also be used for writing desktop graphical user interface (GUI) applications, by using the or discontinued PHP-GTK extension. PHP-GTK is not included in the official PHP distribution, 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 by compiling it from the source code. When PHP is installed and used in cloud environments, software development kits (SDKs) are provided for using cloud-specific features. For example: Amazon Web Services provides the AWS SDK for PHP Microsoft Azure can be used with the Windows Azure SDK for PHP. Numerous configuration options are supported, affecting both core PHP features and extensions. Configuration file php.ini is searched for in different locations, depending on the way PHP is used. The configuration file is split into various sections, while some of the configuration options can be also set within the web server configuration. == Security == In 2019, 11% of all vulnerabilities listed by the National Vulnerability Database were linked to PHP; 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). 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 has been proposed for PHP in the past, but either been rejected or the proposal abandoned. Third-party projects such as Suhosin and Snuffleupagus aim to remove or change dangerous parts of the language. 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 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&nbsp;5.3.0, and removed from PHP&nbsp;5.4.0. Another example for the potential runtime-settings vulnerability comes from failing to disable PHP execution (for example by using the engine configuration directive) for the directory where uploaded files are stored; enabling it can result in the execution of malicious code embedded within the uploaded files. The best practice is to either locate the image directory outside the document root available to the web server and serve it via an 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) in a shared web hosting environment can lead to security issues. 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 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 ( ), which is zero. Errors like this resulted in authentication vulnerabilities in Simple Machines Forum, Typo3 and phpBB when MD5 password hashes were compared. The recommended way is to use hash_equals() (for timing attack safety), strcmp or the identity operator ( === ), as results in false . In a 2013 analysis of over 170,000 website defacements, published by Zone-H, the most frequently (53%) used technique was the exploitation of file inclusion vulnerability, mostly related to insecure usage of the PHP language constructs include , require , and allow_url_fopen .",
  "categories": [
    "101754115",
    "102876480",
    "112857968",
    "113832365",
    "116685905",
    "127051094",
    "1868465",
    "20161863",
    "22896554",
    "22942235",
    "22947481",
    "22985424",
    "22985480",
    "23118434",
    "23284516",
    "23302284",
    "23603337",
    "24745122",
    "24745126",
    "24769763",
    "27068476",
    "27367242",
    "27367243",
    "27449036",
    "27515961",
    "28075870",
    "28081657",
    "28814332",
    "29815558",
    "29815561",
    "30021527",
    "31167261",
    "33308722",
    "3469197",
    "39691156",
    "40211111",
    "41309532",
    "50510567",
    "5747264",
    "63706498",
    "9229844"
  ],
  "license": "CC BY-SA 4.0",
  "source_uri": "https://en.wikipedia.org/w/index.php?oldid=1377202799",
  "content_hash": "",
  "created_at": null,
  "updated_at": 1790575068.0,
  "claims": [
    {
      "id": 29394258,
      "subject_qid": "",
      "subject_slug": "php",
      "predicate": "date of formation",
      "object_text": "2014",
      "object_num": 20140000.0,
      "object_unit": null,
      "polarity": 1,
      "qualifier": "",
      "source_uri": "https://en.wikipedia.org/w/index.php?oldid=1377202799",
      "source_name": "Wikipedia",
      "source_tier": 3,
      "retrieved_at": 1792482461.7420108,
      "confidence": 0.95,
      "article_slug": "php",
      "span_start": 44,
      "span_end": 90
    },
    {
      "id": 29394256,
      "subject_qid": "",
      "subject_slug": "php",
      "predicate": "release date",
      "object_text": "1995",
      "object_num": 19950000.0,
      "object_unit": null,
      "polarity": 1,
      "qualifier": "",
      "source_uri": "https://en.wikipedia.org/w/index.php?oldid=1377202799",
      "source_name": "Wikipedia",
      "source_tier": 3,
      "retrieved_at": 1792482461.7420096,
      "confidence": 0.95,
      "article_slug": "php",
      "span_start": 72,
      "span_end": 89
    },
    {
      "id": 29394257,
      "subject_qid": "",
      "subject_slug": "php",
      "predicate": "release date",
      "object_text": "1997",
      "object_num": 19970000.0,
      "object_unit": null,
      "polarity": -1,
      "qualifier": "",
      "source_uri": "https://en.wikipedia.org/w/index.php?oldid=1377202799",
      "source_name": "Wikipedia",
      "source_tier": 3,
      "retrieved_at": 1792482461.7420106,
      "confidence": 0.95,
      "article_slug": "php",
      "span_start": 437,
      "span_end": 472
    }
  ],
  "contradictions": [],
  "confidence": 0.95,
  "csl": {
    "id": "enwiki-001377202799",
    "type": "webpage",
    "title": "PHP",
    "author": [
      {
        "family": "Anticloud FZ LLE",
        "literal": "Anticloud FZ LLE"
      }
    ],
    "container-title": "encyclopegia.org",
    "publisher": "Anticloud FZ LLE",
    "publisher-place": "Dubai, United Arab Emirates",
    "URL": "https://encyclopegia.org/a/php",
    "issued": {
      "date-parts": [
        [
          2026,
          11,
          18
        ]
      ]
    },
    "accessed": {
      "date-parts": [
        [
          2026,
          11,
          18
        ]
      ]
    },
    "license": "CC BY-SA 4.0",
    "DOI": "eo1:enwiki-001377202799",
    "isBasedOn": "https://en.wikipedia.org/w/index.php?oldid=1377202799",
    "note": "Immutable snapshot enwiki-001377202799"
  }
}