__clone ()-Automatically load this method when the object is cloned__tostring ()-Automatically loads this method when an object needs an echo print output__clone ()PB = ++self:: $pa; } Public Function __clone () { $this->PB = ' no
The current row number in the _ LINE _ file. Website promotionThe complete path and FILE name of the _ FILE. If it is used in a file to be included, the file name to be included is returned. Starting from PHP 4.0.2, __file _ always contains an
This article introduces several magic methods in php object-oriented language and describes them in detail, hoping to help new users. In PHP versions later than PHP 5, classes in PHP can use magic methods. It specifies that all methods starting with
Magic Functions
_ Construct ()
An object is called when it is instantiated. When _ construct and a function with the class name coexist, __construct will be called, and the other will not be called.
_ Destruct ()
It is called when an object
After PHP5.0, php provides more object-oriented methods to make php more powerful !!Some functions called magic methods in PHP are introduced here: in fact, they are used in common applications !!1. _ construct () when instantiating an object, this
Summary of magic methods in PHP: __construct, _ destruct, _ call, _ callStatic, __get, _ set, _ isset, _ unset, _ sleep, _ wakeup, _ toString, _ set_state, _ clone and _ autoload
1. _ get, _ set
These two methods are designed for attributes that are
Copy codeThe Code is as follows:/** PHP treats all class Methods Starting with _ (two underscores) as magic methods. Therefore, when you define your own class methods, do not use _ as the prefix. **/
// _ ToString, _ set, _ get _ isset (), and _
Magic variablePHP provides a large number of predefined constants to any script it runs.However, many constants are defined by different extensions, and are only present when the extensions are loaded, either dynamically after loading, or they are
This article introduces several magic methods in php object-oriented language and describes them in detail, hoping to help new users.
This article introduces several magic methods in php object-oriented language and describes them in detail, hoping
After PHP5.0, php provides more object-oriented methods to make php more powerful !!Some functions called magic methods in PHP are introduced here: in fact, they are used in common applications !!1. _ construct () when instantiating an object, this
What is a magic function?For functions starting with _, they are named Magic functions. These functions are triggered under specific conditions, such as _ set () _ get ().Triggered when setting or retrieving nonexistent attributes.What about the
Ec (2); 1. _ Construct () is called when an object is instantiated. When _ construct and a function with the same class name exist at the same time, __construct is called, and the other is not called. 2. _ Destruct () is called when an object or
_ Construct () when the object is initialized _ destruct () when the object is destroyed _ clone () when the object is cloned _ call () _ callStatic () when calling an inaccessible method in an object in a static way _ get () read the inaccessible
Php built-in variable: DIRECTORY_SEPARATORDIRECTORY_SEPARATOR is a php built-in command that returns path delimiters related to the operating system. It returns/on windows, and regrets/on linux or unix-like, it is usually used when defining the path
An object is called when it is instantiated. When _ construct and a function with the class name coexist, __construct will be called, and the other will not be called.
1. magic functions
(13)
1. _ construct ()
An object is called when it is
Once remember that bird brother Laruence not recommended the use of "magic Method", since then once involved in the use of magic method, I will subconsciously think about it, so good photo? Since this one to two years has been busy working and
For a function starting with _, it is named as a magic function, which is triggered under specific conditions. for example, __set () _ get () is triggered when a nonexistent attribute is set or retrieved. what is a magic function?
For functions
In object-oriented programming, PHP provides a series of magic methods that provide a lot of convenience for programming. The Magic method in PHP usually starts with (two underscores) and does not require a display of calls but a certain set of
Magic methods start with _ in php5. they have magic functions that can bring many benefits to my development, next I will introduce some usage of magic methods and some magic methods in php. The magic method is to underline quot ;__ quo... magic
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.