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} } } ?> Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/290520-magic-methods/#findComment-1488166 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.