Reputation: 2576
How do PHP server pages handle multiple requests from different users?
I am used to C-like languages and they use multithreading. What does PHP use in this case?
Upvotes: 0
Views: 588
Reputation:
It's actually a good question. Once several users try send requests to the same server , no confilct happens becuase the webserver creates an independent process, which you can call a session ( not a php session ) of it's own for each request. PHP has nothing to do with this becuase it's only a script which is finally translated by the a machine .
Upvotes: 1
Reputation: 7181
That's really dependant upon the server you're using to handle these requests. PHP itself does not handle requests, but instead is used to parse the script and return the result. It is possible to write a web server in PHP but then again, this is all dependent on the server you are using.
Upvotes: 1
Reputation: 23777
The PHP interpreter is generally invoked by a webserver (like apache, lighthttpd, ...). The webserver then handles the requests (by threading, forking or whatever). Every instance of PHP is running sequentially, so there is no builtin multithreading.
There exists a PECL extension https://github.com/krakjoe/pthreads which adds multithreading to PHP.
Upvotes: 6