PHP Magic functions and variables

Source: Internet
Author: User

__invoke () The Magic method is called when an object is called as a function:
__callstatic () is called when a static method that does not exist is called.

PHP Magic functions and variables
  Source: http://ruby8.iteye.com/blog/626982 1: Magic function     __construct () is called when instantiating an object.     When __construct and a function with a class name are present, __construct is called and the other is not called.    __destruct () is called when an object is deleted or when an object operation terminates. The    __call () object calls a method that is called directly if the method exists, or calls the __call function if it does not exist.    __get () when reading an object's properties. If the attribute exists, the property value is returned directly, and if it does not exist, the __get function is called.    __set () sets the property of an object. If the attribute exists, it is assigned directly, and if it does not exist, the __set function is called.     __tostring () is called when an object is printed. such as Echo $obj, or print $obj;    __clone () is called when cloning an object. such as: $t =new Test (), $t 1=clone $t;    __sleep () serialize was called before. If the object is relatively large, want to cut a bit of the east and then serialize, you can consider this function.     __wakeup () Unserialize is called to do some initialization of the object.     __isset () detects if a property of an object is present when it is called. such as: Isset ($c->name).     __unset () unset the property of an object is called. such as: unset ($c->name).     __set_state () is called when Var_export is called. Use the return value of __set_state as the return value of Var_export.     __autoload () when an object is instantiated, the method is called if the corresponding class does not exist. 2: Magic variable     __LINE__ returns the current line number in the file.     __FILE__ Returns the full path and file name of the file. If used in the include file, the include filename is returned. Since PHP 4.0.2, __file__ alwaysContains an absolute path, and the previous version sometimes contains a relative path.     __FUNCTION__ returns the function name (PHP4.3.0 new). Since PHP5 this constant returns the name (case-sensitive) when the function is defined. In PHP4, the value is always lowercase.     __CLASS__ Returns the name of the class (PHP4.3.0 new addition). Since PHP5 this constant returns the name (case-sensitive) when the class is defined. In PHP4, the value is always lowercase.     __METHOD__ Returns the method name of the class (PHP5.0.0 new). Returns the name of the method when it is defined (case-sensitive).

PHP Magic functions and variables

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.