一个php文件打开一个进程,但随后该进程关闭?
如果一个Web用户正在进入我的php网站并与之交互,那么这个php文件将打开一个进程(带有一个线程),然后在php文件完成逻辑并将输出发送到浏览器之后,然后关闭该进程?
因为如果它没有关闭,那么这意味着该 php 文件中的变量值将被取消删除,对吧?但由于您总是必须用值初始化新变量,这意味着进程已关闭?
我只是在传统的桌面应用程序中考虑了这个原因,我认为除非您将其关闭,否则该进程不会关闭。
if one web user is entering my 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
PHP 是请求驱动的。 Web 服务器的交互如您所描述的。
是的,桌面应用程序和服务器上运行的 php 脚本在这些方面有很大不同。
PHP is REQUEST driven. The interaction of a web server is as you described.
Yes, a desktop application and a php script running on a server are very different in those terms.
这取决于配置。例如,如果 php 作为 FastCGI 运行,则进程不会关闭,并将继续运行等待新请求。
无论配置如何,您都可以确定一件事:当脚本结束时,所有变量/等都将未初始化,因此您(程序员)不必担心这一点。无论配置如何以及进程是否关闭,它的行为都是相同的。
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.