Given this line of code to callback a function and the callback function itself:
Class MyClass {
public function doThings() {
$this->gearman->client->setCompleteCallback("workerCompleted");
}
public function workerCompleted() {
echo "worker is completed!";
}
}
I get Message: GearmanClient::setCompleteCallback(): function workerCompleted is not callable
The setCompleteCallback method expects a function name in quotations, but how do I call a class method? $this->"workerCompleted" obviously is wrong.
should be
Because you’re specifying a callback to a member function, which requires an array of the object (or classname) that needs to be called, along with the name of the function. More info at the docs.