This is not PHP, but a web server that processes requests. PHP does not work on its own. If the web page contains PHP code, such a request is delegated by PHP through the appropriate PHP SAPI module. There are multi-threaded multiprocessor web servers, and you can even imagine a single process web server, so it depends only on the web server if a separate thread or process is created for the request.
In many places in the PHP documentation, you may find lines like this on umask() :
Avoid using this feature in multi-threaded web servers. Better change the file permissions with chmod () after creating the file. Using umask () may lead to unexpected behavior of running the scripts and the web server itself at the same time, because they all use the same umask.
... how long does this thread remain alive? Does this thread support all static variables correctly? (e.g. database connection)
It sounds like a C ++ background. You probably mean global variables in PHP. PHP has built-in support for database connections, and you should not worry about such things. This is an implementation detail. Most SAPIs provide persistent database connections, but this is only for your curiosity. Persistent connections are created, one for each process that processes requests. Therefore, in this case, they are supported more by the process than by the thread.
When this thread is destroyed, does it call all destructors?
In PHP, destructors are called when a script completes execution. From the point of view of PHP developers, it doesn't matter where the script lives.
doc
source share