Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0按照示例做报错啊Exception Argument func must be callable. #138

Open
zxh451200 opened this issue Jun 27, 2020 · 2 comments
Open

Comments

@zxh451200
Copy link

namespace App\Http\Controllers;

use Hprose\Http\Server;

class Test
{
public function index()
{
$server = new Server();
$server->addFunction('hello');
$server->start();

}

function hello($name) {
    return "Hello $name!";
}

}

Exception
Argument func must be callable.

Snipaste_2020-06-27_11-26-35

@zxh451200 zxh451200 changed the title 2.0按照示例做报错啊 2.0按照示例做报错啊Exception Argument func must be callable. Jun 27, 2020
@andot
Copy link
Member

andot commented Jun 28, 2020

你的hello是个方法,不是个单独的函数,所以不能用 addFunction('hello') 的方式。要用 addFunction([$this, 'hello']) 这种方式。

@andot
Copy link
Member

andot commented Jun 28, 2020

3.0 addFunction 换成 addCallable 就行了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants