Jump to content

[SOLVED] Assigning function to variable


Valect

Recommended Posts

I've been trying to pass a function name to a variable to store it and run it later.. here's a snippet:

$this->timer(1,"ping",$this->action->ping(),REPEAT);

Not putting "$this->action->ping()" in quotes runs it, however putting it in quotes results in the error:

Catchable fatal error: Object of class actions could not be converted to string...

function timer($wait,$name,$what,$repeat) {
$this->holder['timer'][$name]['runtime']	= time() + $wait;
$this->holder['timer'][$name]['interval']	= $wait;
$this->holder['timer'][$name]['execTimer']	= $what;
$this->holder['timer'][$name]['repeat']		= $repeat
}

Later in the script is the line to run the function...

$this->holder['timer'][$name]['execTimer'];

 

I've tried serizlization and some other methods.. I think I'm just going about this all wrong. Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/76800-solved-assigning-function-to-variable/
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.