Php 如何在sh服务框架中创建动态路由
请帮助我,如何在php sh服务框架中创建自定义路由。试试这个:Php 如何在sh服务框架中创建动态路由,php,web-services,frameworks,Php,Web Services,Frameworks,请帮助我,如何在php sh服务框架中创建自定义路由。试试这个: $app->get('/name/:firstname',function($app,$req,$res){ $res->json($req->firstname); } 它对我有用。非常感谢你,它对我有用 请尝试以下格式: $app->get('/name/:firstname',function($app,$req,$res){ echo $req->firstname;
$app->get('/name/:firstname',function($app,$req,$res){
$res->json($req->firstname);
}
它对我有用。非常感谢你,它对我有用 请尝试以下格式:
$app->get('/name/:firstname',function($app,$req,$res){
echo $req->firstname;
}
$app->get('/name/{firstname}',function($app,$req,$res){
$res->json($req->firstname);
}
不要尝试此格式:
$app->get('/name/:firstname',function($app,$req,$res){
echo $req->firstname;
}
$app->get('/name/{firstname}',function($app,$req,$res){
$res->json($req->firstname);
}
请阅读并了解如何创建