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()
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.