php automated setter and getter
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to implement some automated getter and setter for php objects. My target is to automatically have for each properties the methods getProperty() and setProperty(value) , that way if the method is not implemented for a property the script will simply set or get the value. An example, to make myself clear: class Foo { public $Bar; } $A = new A(); $A->setBar("bar"); $A->getBar(); // -> output "bar" or class Foo { public $Bar; public function setBar($bar) { $Bar = $bar; } public function getBar($bar) { return 'the value is: ' . $bar; }