这里有很多名字前有双下划线的函数:
__construct,
__destruct,
__call,
__callStatic,
__get,
__set,
__isset,
__unset,
__sleep,
__wakeup,
__toString,
__invoke,
__set_state
__clone
为什么在这些函数之前使用这些下划线?
最佳答案
如前所述here :
PHP reserves all function names starting with __ as magical. It is recommended that you do not use function names with __ in PHP unless you want some documented magic functionality
长话短说,PHP 调用这些函数隐式,您不应该自己使用这种命名约定。
关于php - 为什么在 PHP 函数名中使用双下划线 (__)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5348663/