Will classes in PHP occupy server resources if they are not instantiated? Solution

Source: Internet
Author: User
Will classes in PHP occupy server resources if they are not instantiated? Will classes in PHP occupy server resources if they are not instantiated? Because I want to create a file and put all the classes in one file. This file is included as needed. when class files are loaded, php will compile the classes for class instantiation, when php allocates memory objects for corresponding objects for execution, php allocates memory for the involved attributes. I don't think so, but does this Occupy server resources if the class is not instantiated in PHP?
Will classes in PHP occupy server resources if they are not instantiated? Because I want to create a file, put all classes in one file, and include this file as needed

------ Solution --------------------
When class files are loaded, php will compile the class
Class instantiation, php will allocate memory for the corresponding object
When the object is executed, php allocates memory for the properties involved.

------ Solution --------------------
I don't think so, but this problem is relative. although you don't instantiate it, it brings about a new problem.

Include N class documents and Include 1 class documents which do you think Occupy server resources? Of course, this occupation can be ignored.

You can do this, but I do not recommend that you do so in terms of maintenance and code ease, it will only bring you more trouble. The last reminder is whether you use _ autoload. if not, follow your ideas.

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.