{"canonical_url":"https://engineer.company/glossary/php/","content_markdown":"# PHP\n\n## What it is\n\nPHP is a scripting language that executes on the web server: a request arrives,\nthe PHP code runs, and what reaches the browser is the HTML it produced, never\nthe code itself. The letters now stand for “PHP: Hypertext Preprocessor”, a\nrecursive acronym, though they began as “Personal Home Page”. A PHP file can be\nordinary HTML with code placed between `\u003c?php` and `?\u003e` tags, or it can be pure\ncode that a framework routes every request through. It also runs scripts from\nthe command line, but its design leans towards producing web pages.\n\nIts history starts in 1994, when Rasmus Lerdorf wrote a set of CGI binaries in C\nto count visits to his online résumé and called them Personal Home Page Tools.\nHe released the source in June 1995, and the tools grew into PHP/FI. In 1997\nAndi Gutmans and Zeev Suraski began rewriting the parser, and the result was\nreleased as PHP 3.0 in June 1998 under the recursive name; at its peak it was\ninstalled on roughly 10% of the web servers on the internet. Their next engine,\nthe Zend Engine, named after the two of them, carried PHP 4.0 in May 2000, and\nPHP 5 followed in July 2004.\n\nOn a server today PHP is commonly run by PHP-FPM, the FastCGI Process Manager\nthat ships with it. A web server in front passes each PHP request to a pool of\nworker processes; each pool can run as its own user and group, with its own\nenvironment and php.ini values, and its process manager keeps a fixed number of\nworkers, starts them on demand, or varies the count between limits. The language\nmoves in release branches, and the last four arrived a year apart. Each branch\ngets two years of active support, with bug and security fixes, then two more\nyears of critical security fixes only, and then reaches end of life. PHP 8.2,\nreleased on 8 December 2022, receives security fixes until 31 December 2026; PHP\n8.5, released on 20 November 2025, until 31 December 2029.\n\nPHP converts between types when an operation calls for it, and the loose\ncomparison operator `==` is where that shows most. If both sides are numeric\nstrings, or one is a number and the other a numeric string, the comparison is\nnumeric. Before PHP 8.0.0 any string compared with a number was converted to a\nnumber first, so `0 == \"a\"` was true. The strict operator `===` compares the\ntype as well as the value and converts nothing, and the manual's own advice is\nto prefer it in most cases.\n\n```php\n\u003c?php\nvar_dump(0 == \"a\");      // PHP 7: true, PHP 8: false\nvar_dump(\"1\" == \"01\");   // true in both: two numeric strings\nvar_dump(\"10\" == \"1e1\"); // true in both: 10 equals 1e1\nvar_dump(100 == \"1e2\");  // true in both\nvar_dump(0 === \"a\");     // false in both: === never converts\n```\n\n## Why it matters\n\nPHP matters mostly because of what is already written in it. WordPress and\nJoomla, the content management systems that a great many organisations use to\nrun sites they edit themselves, are PHP applications: WordPress recommends PHP\n8.3 or greater, and Joomla 6 requires at least PHP 8.3.0. WordPress still runs\non PHP 7.4, though its requirements page warns that such versions have reached\nend of life. A business can depend on PHP for years without anyone in it having\nwritten a line of the language, which is why the version underneath gets\nforgotten. A site keeps serving pages after its branch reaches end of life; it\nsimply stops receiving fixes, and nothing on the screen says so.\n\nUpgrades also change behaviour, quietly. PHP 8.0 changed how strings compare\nwith numbers, so a condition that was true on PHP 7 can be false on PHP 8\nwithout any error. PHP 8.4 raised the default bcrypt cost of `password_hash()`\nfrom 10 to 12, which makes every new password hash more expensive to compute on\nthe same hardware. Both are documented, and each reaches production only through\nan upgrade that someone has to plan, test and own.\n\nOur recommendation is to treat the PHP version as a dependency with an expiry\ndate written next to it. An existing PHP application that works is worth\nkeeping: put it on a supported branch, schedule the next upgrade well before\nsecurity support ends, and give it its own FPM pool and its own system user. For\na new build, choose PHP when the job is a site the client will edit through\nWordPress or Joomla, or when the team that will run it after handover knows PHP\nwell, and choose by that team's skills otherwise. The language is rarely the\nrisk; an unowned version is.\n\n## What it looks like in practice\n\nThe web tier of [our tech stack](/tech-stack/) puts PHP in a specific place.\nPages that can be files are built statically, avoiding request-time application execution for those pages, and this site is built by Hugo; Django and PHP are used where\nthere is an application to serve. The same page states how the choice is made:\nfor the problem, for what the client's team can operate after we leave, and for\nhow the thing fails rather than how it demonstrates. That rule covers PHP\ndirectly: when the right answer is the stack a client already has, the page\ncommits to saying so.\n\nFrom 2015 to 2022, the founder worked as GIS software development team lead, taking\n[more than thirty GIS projects](/portfolio/led-30-gis-projects-from-build-to-support/)\nthrough development, deployment and support once they were live. PHP was one\nof four languages in their application layer, next to JavaScript, Python and\nSQL; below it all the spatial data sat in PostgreSQL with PostGIS, and in front\nwere Mapbox GL and Leaflet maps, some of them calling the ArcGIS or HERE APIs.\nWhatever the language, the responsibility ran past shipping and problems were\nnot handed off: you design differently when you know you are the one getting\nthe call if it breaks.\n\n## Where it goes wrong\n\n- **A loose comparison guards a secret.** A token or a hash checked with `==` is\n  compared by PHP's numeric rules whenever both sides look like numbers, so two\n  different strings such as `\"10\"` and `\"1e1\"` count as equal. Use\n  `password_verify()` for passwords and `hash_equals()` for other secrets: its\n  running time leaks nothing about the contents of the secret, and it expects\n  the user's string as its second argument. Use `===` everywhere else.\n- **SQL is assembled from request data.** PDO prepared statements quote their\n  parameters, and the manual says an application that uses them exclusively is\n  protected from SQL injection, with one stated exception: any part of the query\n  still built from unescaped input. A placeholder stands for a whole value, so\n  anything that is not a value, such as the column a list is sorted by, still\n  ends up in the string. Check those parts against a fixed list in code.\n- **Password hashes are stored too narrowly.** `PASSWORD_DEFAULT` is bcrypt\n  today, and the manual warns that it is designed to change as stronger\n  algorithms are added. It recommends a column that can expand beyond 60 bytes,\n  with 255 as a good choice. Bcrypt also truncates the password at 72 bytes.\n  Store the whole hash, and call `password_needs_rehash()` after a successful\n  login so older hashes are upgraded as people sign in.\n- **The branch passes its end-of-life date.** The application keeps working, so\n  nobody schedules the upgrade, and the eventual jump spans several branches at\n  once. Record the security-support date of the branch in use, upgrade one\n  branch at a time, and run the test suite against the next branch before the\n  current one expires.\n- **The FPM pool is shared and loose.** One pool serving several applications as\n  one user lets a flaw in one reach the files of all.\n  `security.limit_extensions` defaults to `.php .phar`, and the manual advises\n  limiting it to `.php` so a misconfigured web server cannot hand other files to\n  PHP. Give each application its own pool and user, and set `pm.max_children` to\n  what the server's memory can hold.\n\n## Further reading\n\n- [PHP Manual: What is PHP?](https://www.php.net/manual/en/introduction.php) —\n  the project's own short definition, with the first example of PHP embedded in\n  HTML.\n- [PHP: Supported Versions](https://www.php.net/supported-versions.php) — the\n  support policy and the active and security-only dates of every current branch.\n- [PHP Manual: Comparison Operators](https://www.php.net/manual/en/language.operators.comparison.php)\n  — loose and strict comparison, the PHP 7 and PHP 8 outputs side by side, and\n  the comparison table by type.\n- [PHP Manual: password_hash](https://www.php.net/manual/en/function.password-hash.php)\n  — algorithms, cost, column width, the 72-byte limit and the change of default\n  cost in 8.4.\n- [PHP Manual: Prepared statements and stored procedures](https://www.php.net/manual/en/pdo.prepared-statements.php)\n  — how PDO binds parameters and where SQL injection is still possible.\n- [PHP Manual: FPM configuration](https://www.php.net/manual/en/install.fpm.configuration.php)\n  — pool directives, the process manager modes, `clear_env` and\n  `security.limit_extensions`.\n\n\u003chttps://engineer.company/glossary/php/\u003e\n","date_modified":"2026-11-12T05:34:23Z","description":"What PHP is, how it serves a page, where its loose comparisons and support dates catch teams out, and how to keep an inherited PHP site safe.","formats":{"gemtext":"https://engineer.company/glossary/php/index.gmi","gopher":"https://engineer.company/glossary/php/gophermap","html":"https://engineer.company/glossary/php/","json":"https://engineer.company/glossary/php/index.json","markdown":"https://engineer.company/glossary/php/index.md","pdf":"https://engineer.company/glossary/php/index.pdf"},"kind":"page","language":"en","title":"What is PHP?","url":"https://engineer.company/glossary/php/","version":1}