开发者

Using php's magic methods outside a class

开发者 https://www.devze.com 2022-12-27 19:57 出处:网络
开发者_如何转开发Is it possible to use PHP magic methods (specifically __get()) outside a defined class?

开发者_如何转开发Is it possible to use PHP magic methods (specifically __get()) outside a defined class?

I'm wanting to use it in a configuration file for quick loading. The configuration file has a single array, $config, with many keys. Therefore, I'd like to override __get() to return the key in the array.


No, but you could write an object that reads the config file, and provides the __get method.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号