On 05/29/2014 08:14 AM, Jim Lucas wrote:
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)};
}
Better yet, rearrange things a little.
$method = 'get' . ucfirst($property);
if ( method_exists($object, $method) ) {
$children = $object->$method();
}
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