Jump to content

magic methods


Destramic

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.