Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 我什么时候应该/应该在 PHP 中使用 __construct()、__get()、__set() 和 __call()?
这是我没有找到任何好的答案的一个领域。谁能向我解释为什么/如何正确使用它们?它们不只是一个糟糕的设计决定吗?
我认为文档解释得最好。它被称为重载。
__set()在将数据写入不可访问的成员时运行。 __get()用于从不可访问的成员中读取数据。
__set()在将数据写入不可访问的成员时运行。
__set()
__get()用于从不可访问的成员中读取数据。
__get()
它也有一些使用这些的例子。