PHP 16 Magic Methods Detailed Introduction

Source: Internet
Author: User
Tags export class

PHP, which starts with two underscores, is called the Magic Method (Magic methods), which plays a pivotal role in PHP. Here is a detailed introduction, interested in the small friends can refer to.

PHP, which starts with two underscores, is called the Magic Method (Magic methods), which plays a pivotal role in PHP. Magic methods include:

    • __construct (), constructor of class
    • __destruct (), Destructor for class
    • __call (), called when an inaccessible method is called in an object
    • __callstatic (), called when a non-accessible method is called in a static manner
    • __get (), which is called when a member variable of a class is obtained
    • __set (), which is called when a member variable of a class is set
    • __isset (), called when isset () or empty () is called on an inaccessible property
    • __unset () is called when unset () is called on a non-accessible property.
    • __sleep (), when executing serialize (), this function is called first
    • __wakeup (), when executing unserialize (), this function is called first
    • __tostring (), which is a method of responding when a class is treated as a string
    • __invoke (), called when a function is called in a way that responds to an object
    • __set_state (), this static method is called when the Var_export () export class is called.
    • __clone (), called when the object copy is complete
    • __autoload (), attempting to load an undefined class
    • __debuginfo () to print the required debug information

For more information, please see below:

http://php.net/manual/zh/language.oop5.magic.php

Ext.: http://www.jb51.net/article/96167.htm

PHP 16 Magic Methods Detailed Introduction

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.