Destramic Posted August 18, 2014 Share Posted August 18, 2014 hey guys im wdondering if there's a magic method which works like __GET() but allows you to put a parameter in...thank you <?php class test { public function run() { $this->object->('string'); // __get with parameter? } public function __get($value) { return $this->{$value} } } ?> Link to comment https://forums.phpfreaks.com/topic/290520-magic-methods/ Share on other sites More sharing options...
Ch0cu3r Posted August 18, 2014 Share Posted August 18, 2014 You mean to say you want to pass arguments to __get when you call a property? That is not possible and just weird. When you access a property PHP auto-magically calls __get passing the property name as an argument. I think you may be interested in __set if you are wanting to set a properties value? When you assign a value to a property PHP will auto-magically call __set passing in the property name and value as arguments Link to comment https://forums.phpfreaks.com/topic/290520-magic-methods/#findComment-1488166 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.