I have compiled some of the PHP magic methods that will be used frequently in the development process, hoping to be helpful to everyone.
The Magic method is a predefined function in PHP that has a special purpose (which is triggered under certain
Summary and usage examples of magic methods in PHP
This article mainly introduces the Magic method in PHP summary and use examples, the Magic method is the PHP object-oriented features, they are triggered in a particular case, are to start with a
The second article in the object-oriented series of PHP-magic methods and object orientation× Directory [1] constructor [2] constructor [3] inaccessible properties [4] object copy [5] string [6] object does not exist [7] automatic loading class [8]
Summary of Magic Methods in PHP: __construct, __destruct, __call, __callstatic,__get, __set, __isset, __unset, __sleep, __wakeup, __toString , __set_state, __clone and __autoload1, __get, __setThese two methods are designed for properties that are
Summary of Magic Methods in PHP: __construct, __destruct, __call, __callstatic,__get, __set, __isset, __unset, __sleep, __wakeup, __toString , __set_state, __clone and __autoload1, __get, __setThese two methods are designed for properties that are
Summary of Magic Methods in PHP: __construct, __destruct, __call, __callstatic,__get, __set, __isset, __unset, __sleep, __wakeup, __toString , __set_state, __clone and __autoload1, __get, __setThese two methods are designed for properties that are
Mr. Mak introduction: In Learning PHP object-oriented programming ideas, we will encounter a lot of automatic call magic method, each magic method has its own specific triggering scenario, but its fundamental purpose is to write and actual use of
Summary and examples of magic methods in PHP
This article mainly introduces the summary and examples of the magic methods in PHP. The magic method is a special feature of PHP object-oriented, which is triggered under specific circumstances and
Summary of Magic Methods in PHP: __construct, __destruct, __call, __callstatic,__get, __set, __isset, __unset, __sleep, __wakeup, __toString , __set_state, __clone and __autoload1, __get, __setThese two methods are designed for properties that are
Magic Method (Magic methods)PHP, which starts with two underscores __ , is called the Magic Method, which plays a pivotal role in PHP. Magic methods include:
__construct(), the constructor for the class
__destruct(), a destructor for a class
Type Conversion MagicType Conversion magic is actually the result of implementing factory functions such as STR, int, and usually these functions have the function of type conversion, here are some related magic methods:
__int__ (self)
Php object-oriented advanced-magic methods and iterators, php object-oriented magic
1. Magic Methods _ set and _ get, _ call
> These magic methods will be called when the relevant property or method does not exist.
> Function prototype
. Function _
Magic constant:1. _ LINE __Returns the current row number in the file.2. _ FILE __Returns the complete file path and file name. If it is used in a include file, the include file name is returned. From PHP4.0.2, __file _ always contains an absolute
PHP (foreign name: HypertextPreprocessor, Chinese name: "Hypertext Preprocessor") is a common open source scripting language. The syntax absorbs the features of C language, Java, and Perl. it has a low entry threshold, is easy to learn, and is
Here are just a few of the magic methods that may be commonly used, such as __new__, which is not commonly used for meta-class initialization or __init__, is not introduced by anyone who uses this initialization.In fact, each magic method is in the
Several common php magic methods are introduced! (1) _ get and _ set methods. when the reference class does not contain members, you can call two methods. The _ set method must accept two parameters, used to store the name and attribute value of the
Objective: To learn the magic methods of class in python to improve the efficiency of programming.Environment: Ubuntu 16.4 python 3.5.2Learning class is bound to come into contact with its magic methods, such as commonly used __init__, the form is
PHP is called the Magic Method (Magic methods), which starts with two underscores, and these methods play an important role in PHP. Magic methods include:
__construct (), constructor for class
__destruct (), Destructor of class
__call ()
PHP5.3 has added a magic method called __invoke so that you can call the object directly after you create the instance.
Class TestClass
{
Public Function __invoke
{
print "Hello World";
}
}
$n = new TestClass;
$n ();
The results of the
I'll explain all the magic methods in PHP below. In fact, most of the following methods, for a qualified PHP programmer, are very familiar with things. I am here to make a summary, I make a record of learning, but also not familiar with these
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.