About PHP magic method description

WBOY
Release: 2016-08-08 09:33:11
Original
1468 people have browsed it

From php5 and later versions, classes can use magic methods. PHP stipulates that methods starting with two underscores (__) are reserved as magic methods, so it is recommended that function names do not start with __ unless it is to overload existing magic methods.

At present, all the magic methods in PHP include the following:

__construct() __destruct() __call() __callStatic() __get() __set() __isset() __unset() __sleep() __wakeup() __toString() __invoke() __set_state() __clone() __debuglnfo()
Copy after login

Why study these magic methods can enrich our knowledge. Programmers are like this. When you feel that you need a certain knowledge point, you will definitely study it.

It can be seen here that the names of magic methods all start with '__', which is two '_'

So we should not use '__' when defining class methods.

The above has introduced the description of PHP magic methods, including the content of PHP magic methods. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!