What is the life cycle of the next PHP single case?
For example, I get a singleton in the first request and then assign the variable $ A to it. Does this make it possible to get this $ A variable when a second request is made?
About this knowledge, experienced pro, what good blog or book recommended to learn, thank you?
Reply content:
What is the life cycle of the next PHP single case?
For example, I get a singleton in the first request and then assign the variable $ A to it. Does this make it possible to get this $ A variable when a second request is made?
About this knowledge, experienced pro, what good blog or book recommended to learn, thank you?
No, PHP is a single-process one-thread
The answer is no, because at the end of the script all the variables have been freed.
I think you need to know the life cycle of PHP.
1. PHP是随着WEB服务器(apache)的启动而运行的; 2. PHP通过mod_php5.so()模块和服务器(apache)相连 3. PHP总共有三个模块:内核、Zend引擎、以及扩展层; 4. PHP内核用来处理请求、文件流、错误处理等相关操作; 5. Zend引擎(ZE)用以将源文件转换成机器语言,然后在虚拟机上运行它; 6. 扩展层是一组函数、类库和流,PHP使用它们来执行一些特定的操作。比如,我们需要MySQL扩展来连接MySQL数据库; 7. 当ZE执行程序时可能会需要连接若干扩展,这时ZE将控制权交给扩展,等处理完特定任务后再返还; 8. 最后,ZE将程序运行结果返回给PHP内核,它再将结果传送给SAPI层,最终输出到浏览器上。