Can PHP's singleton persist until the second request is sent?

Source: Internet
Author: User
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层,最终输出到浏览器上。    
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.