Can the php Singleton be stored until the second request is sent?

Source: Internet
Author: User
What is the lifecycle of the PHP Singleton? For example, I obtain a singleton in the first request and assign a value to the variable $. In this way, can the $ a variable be obtained in the second request? What kind of excellent blog posts or... can you tell me about the lifecycle of the PHP Singleton?
For example, I obtain a singleton in the first request and assign a value to the variable $. In this way, can the $ a variable be obtained in the second request?
Do you have any excellent blog posts or books to recommend? thank you?

Reply content:

What is the lifecycle of the PHP Singleton?
For example, I obtain a singleton in the first request and assign a value to the variable $. In this way, can the $ a variable be obtained in the second request?
Do you have any excellent blog posts or books to recommend? thank you?

IMPOSSIBLE. php is single-process, single-thread

The answer is no, because all variables are released at the end of the script.

I think you need to understand the lifecycle of php.

1. PHP runs with the startup of the WEB server (apache); 2. PHP is connected to the server (apache) through the mod_php5.so () module. 3. PHP has three modules: Kernel, Zend Engine, and extension layer. 4. the PHP kernel is used to process requests, file streams, error handling, and other related operations. 5. the Zend Engine (ZE) is used to convert the source file to the machine language, and then run it on the virtual machine; 6. the extension layer is a set of functions, class libraries, and streams. PHP uses them to perform certain operations. For example, we need MySQL extension to connect to the MySQL database; 7. when ZE executes the program, it may need to connect several extensions. Then ZE gives control to the extension and returns the control after processing the specific task. 8. finally, ZE returns the program running result to the PHP Kernel. it then delivers the result to the SAPI layer and finally outputs the result to the browser.

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.