Php destructor usage summary _ javascript skills

Source: Internet
Author: User
This article mainly introduces the usage of php destructor in detail. If you need a friend, you can refer to it and hope to help you briefly, the Destructor is used to complete special work when the object is closed. For example, I wrote a previous example to open a file while instantiating it. But when will it be closed? Close it when it is used up, so when the Destructor closes it directly, or when the Destructor is performed, we write some processed data into the database. At this time, we can consider using the destructor to complete the process, before the Destructor is complete, these object attributes still exist and are only used for internal access, therefore, you can safely perform any aftermath analysis functions related to objects, instead of releasing the object's memory, instead, you can use it to guide the internal existence of php to be released when the user needs to release some additional memory. Finally, php uses

The Code is as follows:


Class x
{
Function _ construct ()
{
$ This-> file = fopen ('path', 'A ');
}
Function _ destruct ()
{
Fclose ($ this-> file );
}
}

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.