PHP magic constant 1 ,__ complete path and FILE name of FILE. If it is used in a file to be included, the file name to be included is returned. Starting from PHP4.0.2, __file __? It always contains an absolute path (if it is a symbolic link, it is
Php Magic Method __get, __set use instance, __get__set
__get ()-__get () is called when the value of the Inaccessible property is read.
__set ()-__set () is called when a value is assigned to an inaccessible property.
Copy the Code code as follows:
PHP Magic Method __isset __unset (c), __isset__unset
Slowly long search night, the moon hanging
__isset ()-a method that automatically executes __isset () if there is no or non-public property when using the Isset () method on a property in a class
PHP Magic Method __construct __destruct (i), phpdestruct
Slowly long search night, the moon hanging
__construct ()-this method is called each time a new object is created
__destruct ()-All references to an object are deleted or executed when an
Php's method of starting with two underscores is called a magic method, which plays a pivotal role in PHP. Magic methods include: __construct (), class constructor __destruct (), Class destructor __call (), call to an inaccessible method in an
PHP Magic methods and Magic variablesMagic Method:PHP treats all class methods starting with __ (two underscores) as a magic method;
__construct (), construction method;
__destruct (), destructor;
__get (String $name) is called when
The Magic method is unique to PHP's object-oriented features. They are triggered in a particular case, they start with a double underscore, you can interpret them as hooks, and you can easily implement the PHP object-oriented overload using the
The example of this article tells the PHP magic variable usage, which __dir__ is php5.3 new, share for everyone reference. The specific usage analysis is as follows:
System constants
__file__ Current file name__LINE__ the current number of
PHP Magic Method __get __set (ii), __get__set
Slowly long search night, the moon hanging
__get ()-__get () is called when the value of the Inaccessible property is read
__set ()-__set () is called when a value is assigned to an unreachable
PHP Magic Method __sleep __wakeup (iv), __sleep__wakeup
Serialization serialize can convert variables including objects into continuous bytes data. You can either have a serialized variable in a file or transfer it over the network. Then crossdress
PHP Magic constant __method__ Introduction, constant __method_
__method__ is a new magic constant after PHP5, representing the name of the class grammar. The magic constant is a PHP predefined constant, its value can be changed, PHP's other
_ File _: a PHP magic constant. It returns the complete path and file name of the currently executed PHP script, including an absolute path.
1) The dirname (_ file ___) function returns the path where the script is located.For example, file B. php
From the later version of PHP5, the class will be able to use the Magic method. PHP rules to start with two underscore (__) methods are preserved as a magic method, it is recommended that the function name is best not to start without __, unless it
From the later version of PHP5, the class will be able to use the Magic method. PHP rules to start with two underscore (__) methods are preserved as a magic method, it is recommended that the function name is best not to start without __, unless it
From the later version of PHP5, the class will be able to use the Magic method. PHP rules to start with two underscore (__) methods are preserved as a magic method, it is recommended that the function name is best not to start without __, unless it
Php magic methods are summarized from versions later than php5, and php classes can use magic methods. Php requires that all methods starting with two underscores (_) are retained as magic methods. Therefore, we recommend that you do not start with _
Defined:
The method that begins with the two line "__" in the PHP class is called the Magic method.
Classification:
For example: Construction method: __construct; destructor: __destruct; dynamic reload: __set (), __get (), __call (), __callstatic ()
PHP has a number of special functions and methods,
these functions and methods compared to the ordinary method of the special point is that the user code is usually not active invocation, but at a specific time will be automatically called by PHP .
PHP magic function application details, read PHP magic function application details, PHP provides two magic reference functions for reference data magic_quotes_gpc and magic_quotes_runtime, these two functions in php. when ini is set to ON, it will
: This article mainly introduces the PHP magic method _ set _ get. if you are interested in the PHP Tutorial, refer to it. Let's take a look at the explanation in the official documentation.
_ Set () is run when writing data to inaccessible
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.