What PHP is and where it runs
PHP is a general-purpose scripting language built for the web. Rasmus Lerdorf released the first version in 1995 as "Personal Home Page Tools"; today the name stands for PHP: Hypertext Preprocessor. You write .php files, and the PHP engine (the Zend Engine) reads, compiles and runs them. There is no separate build step: change the file, run it again, see the result.
PHP mostly runs on a server. A browser never sees your PHP code; it only sees what the script prints — usually HTML or JSON. That is the key difference from JavaScript in the browser.
- 11. A browser asks for a page
It sends an HTTP request for
https://shop.example/cart. - 22. The web server hands it to PHP
Nginx or Apache passes the request to PHP-FPM, a pool of PHP worker processes.
- 33. Your script runs
It reads the request, talks to a database, and
echoes HTML or JSON. - 44. The output goes back
Everything the script printed becomes the HTTP response. Then the script ends and its memory is thrown away — every request starts fresh.
- WordPress — the content system behind a very large share of all websites, written in PHP. Themes and plugins are PHP.
- Laravel and Symfony — the two big PHP frameworks for web apps and APIs. Laravel is the most popular; Symfony components sit inside Laravel, Drupal and many others.
- E-commerce and CMS — WooCommerce, Magento (Adobe Commerce), Drupal, Joomla and MediaWiki (Wikipedia) are PHP.
- Command-line tools — the same PHP runs scripts, cron jobs and queue workers from the terminal, which is how every example in this handbook runs.
match, named arguments, attributes, property hooks and a pipe operator. This handbook teaches that modern PHP, and every example is run with PHP 8.5.