one php-file opens one process but then the process closes?
if one web user is entering my开发者_StackOverflow中文版 php site and interacts with it then this php file will open one process (with one thread) and then after the php file is finnished with the logic and sent the output to the browser then the process is closed?
cause if it wasnt closed then it would mean that the values in the variables in that php file will be undeleted right? but since you always have to initialize new variables with values it means that the process is closed?
i just thought about this cause in a traditional desktop application i think the process doesn´t close unless you shut it down.
PHP is REQUEST driven. The interaction of a web server is as you described.
- The REQUEST comes in to the server
- Apache (example) creates a thread for the php executable
- Your PHP script(s) are fired up, variables are init'd
- Your script(s) complete execution, variables die
- Apache cleans up
- Your get a RESPONSE from the server
Yes, a desktop application and a php script running on a server are very different in those terms.
It depends on the configuration. For example, if php is running as FastCGI, the process will not be closed and will keep running waiting for a new request.
Regardless of the configuration though you can be sure of one thing: all the variables/etc will be uninitialized when the script ends, so you (the programmer) don't have to worry about this. Regardless of the configuration and whether the process closes or not it will behave the same.
精彩评论