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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.