【问题标题】:How to create dynamic routes in sh-service framework如何在 sh-service 框架中创建动态路由
【发布时间】:2017-08-28 01:53:53
【问题描述】:

请帮助我,如何在 php sh-service 框架中创建自定义路由。

【问题讨论】:

标签: php web-services frameworks


【解决方案1】:

非常感谢它对我有用。

试试这个格式:

$app->get('/name/:firstname',function($app,$req,$res){ 

   echo $req->firstname;
}

不要尝试这种格式:

$app->get('/name/{firstname}',function($app,$req,$res){ 

   $res->json($req->firstname);
}

【讨论】:

    【解决方案2】:

    试试这个:

    $app->get('/name/:firstname',function($app,$req,$res){ 
    
       $res->json($req->firstname);
    
    }
    

    它对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-12
      相关资源
      最近更新 更多