没有调用类中的php回调函数

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.

$this->gearman->client->setCompleteCallback("workerCompleted");

should be

$this->gearman->client->setCompleteCallback( array( $this, "workerCompleted"));

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.

Maybe you used the doBackground function to send the code the gearman server? That indeed doesn't use the Callback, since you by definition don't care about the job status and results in your application code.