我正在使用PHP slim框架版本2.在他们的文档中,他们没有指定如何传递参数来调用如何在函数中接收参数。
$app->get('/books/{id}', 'getBook')
function getBook($id){
var_dump($id);
die('there');
}
但它给了我一个错误,或者找不到或者
All Route middleware must be callable
@ owaishanif786我不知道这种方式($ app-> get('/ books / {id}','getBook'))你在你的问题中使用但如果我想在苗条框架2中调用一个函数然后我就像下面这样做,请检查:
$app->get('/total', function() use($app){
test(2);
});
function test($id){
echo "yes you were right $id";
}
现在只需调用/ total api你的函数test(),参数$ id将调用
截至Slim v3
$app->get('/books/{id}', function ($request, $response, $args) {
// $args['id']
});