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
In PHP versions later than PHP 5, classes in PHP can use magic methods. It specifies that all methods starting with two underscores (_) are retained as magic methods. Therefore, we recommend that you do not start with _ In the function name unless
The simple existence of php (one of the magic methods: fault tolerance ). Php simple existence (one of the magic methods: Fault Tolerance) name $ name; $ this-age $ age;} obtain the magic method # @ paramstring $ namepublicfunction _ get ($ param)
: This article mainly introduces the magic methods in php. if you are interested in the PHP Tutorial, you can refer to them. PHP magic method:
_ Construct (), _ destruct (), _ call (), _ callStatic (), _ get (), _ set (), _ isset (), _ unset (), _
Summary of magic methods in PHP: __construct ,__ destruct ,__ call ,__ callStatic ,__ get ,__ set ,__ isset ,__ unset ,__ sleep ,__ wakeup ,__ toString, __set_state ,__ cloneand _ autoload1, _ get, and _ set are designed for attributes not declared
(Basic Python tutorial) learning notes | Chapter 2 | magic methods, attributes, and iterators
This chapter is a little abstract and looks a little painful!
Double underline _ ure _ or single underline has special meanings. in Python, the set of
Let's take a closer look at common PHP object-oriented keywords and magic methods.
Common keywords in PHP object-oriented
Final
1. final cannot modify member attributes (constants in the class do not use this keyword)
2. final can only modify
Php magic methods and magic constants when we learn objects, we often hear teachers say that everything in the world is an object, so we will certainly hear concepts such as magic methods and magic constants, we will summarize the following points
In PHP versions later than PHP 5, classes in PHP can use magic methods. It specifies that all methods starting with two underscores (_) are retained as magic methods. Therefore, we recommend that you do not start with _ In the function name unless
PHP classes can use magic methods in versions later than PHP5. It specifies that all methods starting with two underscores (_) are retained as magic methods. Therefore, we recommend that you do not start with _ in the function name unless you want
Overview
In object-oriented programming, PHP offers 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 need to be displayed but is based on a
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 () Called when
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
This article describes how to use php magic methods (php magic functions). For more information, see
This article describes how to use php magic methods (php magic functions). For more information, see
The Code is as follows:
/** PHP treats
Php magic methods-constructor and destructor, php magic Constructor
Php has a magical class of methods. These methods are reserved and are generally not explicitly called outside. They start with a double underscore, they are called Magic Methods ).
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
Some things, if not used frequently, can easily be forgotten, such as magic methods and magic constants.
Magic Method (Magic methods)
PHP's method of starting with two underscores is called a magic method, which plays a pivotal role in PHP. 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.