# What PHP Is Today — PHP

Source: https://www.skillbyai.com/en/php/f-what

> Describe PHP's role on the web, its execution model and its modern versions.

## A server-side language that grew up

**PHP** is a general-purpose scripting language designed for the web. A web server hands each HTTP request to PHP, which runs your script, produces a response (usually HTML or JSON) and then **throws away all state** at the end of the request: the **shared-nothing** model. That makes PHP simple to deploy and scale horizontally, because no request depends on memory left by another. PHP powers a large share of websites, including WordPress, Wikipedia and many e-commerce platforms, and modern frameworks such as **Laravel** and **Symfony** are widely used for new applications. Forget old reputations: since **PHP 7** (2015), performance roughly doubled, and the **PHP 8** series added a JIT compiler, union types, named arguments, `match`, enums, readonly properties, first-class callables, typed class constants and, in **PHP 8.4**, property hooks and asymmetric visibility. Each version gets two years of active support plus security fixes, so production code should run on a currently supported 8.x release. Package management is handled by **Composer**, and coding standards by the **PHP-FIG** PSR recommendations.

## Request in, response out, state discarded

Each request starts fresh, runs the script and discards its memory when the response is sent.

![A row of separate request bubbles, each passing through a small engine box and producing a page icon, with nothing carried between them.](assets/figures/php/section-1-map.svg) — Figure 1.1 — PHP's shared-nothing request lifecycle.

## A small modern PHP script

Strict types, typed functions and string interpolation.

```php
<?php
declare(strict_types=1);

function greet(string $name, int $hour): string
{
    $part = match (true) {
        $hour < 12 => 'morning',
        $hour < 17 => 'afternoon',
        default    => 'evening',
    };
    return "Good {$part}, {$name}!";
}

echo greet('Asha', (int) date('G')), PHP_EOL;

// run from the terminal:  php hello.php
```

## Always target a supported version

Unsupported PHP versions receive no security fixes. Check the official supported-versions page when starting a project and plan upgrades yearly; modern tooling (Rector, PHPStan) makes them much easier than they used to be.

**Quiz:** What does PHP's shared-nothing model mean?

- [x] Each request starts with fresh state, which is discarded when the request ends
- [ ] All requests share one global memory space
- [ ] PHP cannot use databases
- [ ] PHP runs only on one CPU core

*Answer:* Each request starts with fresh state, which is discarded when the request ends. Request isolation keeps PHP simple to scale; persistent data lives in databases, caches or sessions.
