简体   繁体   中英

Client-Server PHP communication

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?

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.

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM