php - Pass method from controller as callback to another -



php - Pass method from controller as callback to another -

i have this:

public function generateaudio(){ $sourceprocessor = new sourceprocessor($_session['input_file']); $sourceprocessor->extractaudio(); } public function checkprogress($percent){ //do percents }

and in sourceprocessor have this:

public function extractaudio($callback=null, $folder=null){ if(is_callable($callback)){ $callback($percentage); } }

i tried pass method

$sourceprocessor->extractaudio(array($this,'checkprogress'); $sourceprocessor->extractaudio(array($this->checkprogress());

but nil seems work. have thought how this?

call method this:

$sourceprocessor->extractaudio(array($this,'checkprogress'));

and phone call callback extractaudio this:

call_user_func($callback, $percent);

see manual entry call_user_func , callable more information

php yii

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -