在slim框架中:
<?php
namespace Test\SDK\Sample;
require __DIR__ . '/../vendor/autoload.php';
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
$app = AppFactory::create();
$app->get('/hello/{name}', function (Request $request, Response $response, array $args) {
$name = $args['name'];
$response->getBody()->write("Hello, $name");
return $response;
});
我们可以访问:
http://localhost:8080/hello/bob
请问如何在slim获得query参数呢,比如访问:
http://localhost:8080/hello/bob?aaa=111&bbb=222
搜索无结果。
可通过如下方式获取: