PHP is Weird, Stateless, and Beautiful

PHP is, historically, stateless.

This is mostly a result of HTTP being stateless as well. Each HTTP request has no knowledge of any request before it.

PHP is much the same. Under "traditional" process models, it rebuilds its entire world on each request! There's no global state.

Language Comparison

In the video, we compare other popular languages and see how its possible to create a global variable that increases in value with each web request. In other words, there's global state that that you need to worry about.

PHP is different - even global variables are "reset" to their initial value on each request. (This is not to be confused with super globals such as $_GET, $_POST, $_SERVER, and so on).

Pros and Cons

This makes PHP much easier to use - the mental model of what your code is doing is much simpler when there's no state that might be accidentally saved between web requests.

However it also means we need to reload a lot of code on each web request. This is alleviated by PHP's opcache, but it's still not as efficient as having the framework/code loaded already when accepting a new web request.

Additionally, PHP can't make use of things like connection pooling - each web request instead needs to make a whole new connection to databases, caches, and other external services.

This, luckily, is mostly just fine - PHP is still fast!

Newer PHP models

There are newer ways to run PHP - using Swoole or RoadRunner, for example, we can run PHP as a long-running process. This behaves more like other programming languages where we need to worry about global state, but we get the benefit of not having to reload your code/framework on each request.

Laravel has made using this simple via Laravel Octane. However it's still not the mainstream way to run PHP! Given how large PHP is, I'm not sure it ever will be. It's good, but not a silver bullet - everything is a tradeoff.