Re: Building variable getter-method

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/29/2014 07:06 AM, Michael Bakonyi wrote:
Hi,

I'd like to do something like this:

if (method_exists($object, 'get' . ucfirst($property))) {

Untested, but I do recall having to build a temp variable first, then use it in my call. Also, if you are trying to call a method, you forgot the '()'. So...

$method = 'get' . ucfirst($property);
$children = $object->$method();

   $children = $object->{'get' . ucfirst($property)};
}

but this is not working unfortunately – $children is always NULL although the
getter exits. Is there a another way to build a dynamic getter?

Cheers,
Michael



--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux