RE: Referrring to a class object's internal/own function via string referral

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

 



Like this:

array_walk_recursive($arToPass, array($this, "functionName"),
$extraParameter);

It's the same syntax of call_user_func().



Keith Davis (214) 906-5183


-----Original Message-----
From: Jacob Kruger [mailto:jacob@xxxxxxxxxxxxx] 
Sent: Thursday, August 02, 2012 11:49 AM
To: php-windows@xxxxxxxxxxxxx
Subject:  Referrring to a class object's internal/own function
via string referral

I want to make use of array_walk_recursive, inside a function
definition, inside a class definition, to apply another of the class'
internal functions recursively to every member of an array class
property, and one of the parameters it requires is the string name of
the function to implement in it's usage:
bool array_walk_recursive ( array &$input , callable $funcname [, mixed
$userdata = NULL ] )

However, this works fine if I am referring to making use of a sort of
global, externally defined function, but, since you literally pass it
the name of the function to make use of in a string value, how would I
thus refer to a function defined inside the class definition?

This is, since, something along the lines of the following three
examples both don't work for varying/different reasons:
array_walk_recursive($arToPass, "$this->functionName", $extraParameter);
array_walk_recursive($artoPass, '$this->funcName', $extraParameter);
array_walk_recursive($artoPass, "funcName", $extraParameter);

Also tried assigning another variable the value of the function before
then trying to pass it through, but that also doesn't work:
$fn = $this->funcName;
array_walk_recursive($arToPass, $fn, $extraParameter);

Thus, what am wondering is if you need to pass a reference to a function
through to another process/function/method, using the string value of
it's name, etc., how would you then refer to something like the parent
class' internally defined function as such?

TIA

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'


This message (including any attachments) may contain confidential or otherwise privileged information and is intended only for the individual(s) to which it is addressed. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secured or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message or that arise as a result of e-mail transmission. If verification is required please request a hard-copy version from the sender.

www.pridedallas.com


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




[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux