It is not PHP, but web server, which handles requests. PHP is not running by itself. If web page contains PHP code, such request is delegated to PHP by appropriate PHP SAPI module. There are multi-thread, multi-process web servers and one can even imagine single process web server, so it is purely web server dependent if separate thread or process will be created for a request.
In many places of PHP documentation you can meet lines like this one on umask()
:
Avoid using this function in multithreaded webservers. It is better to
change the file permissions with chmod() after creating the file.
Using umask() can lead to unexpected behavior of concurrently running
scripts and the webserver itself because they all use the same umask.
...how long does this thread stay alive? Does this thread maintain all the static variables properly? (like a DB connection)
You sound like one with 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. They are implementation detail. Most SAPIs provide persistent database connections, but this is only for your curiosity. Persistent connections are created one per process, which handles requests. So in this case they are maintained rather by a process than thread.
When this thread is destroyed, does it call all the destructors?
In PHP destructors are being called when script finishes execution. From PHP developer point of view it is irrelevant where script lives.