A
A
Archakov Dennis2016-07-31 17:17:23
PHP
Archakov Dennis, 2016-07-31 17:17:23

Slim 3 doesn't accept GET parameters?

I am writing an API on this framework and I wanted to accept GET parameters, but nothing comes up. Although if you specify the path /send/sms/79999999999 as an argument, it processes normally.

$app->get('/send/sms', function ($request, $response, $args) {
  print_r($_GET);
  print_r($_GET['phone']);
});

ecf46ac893c44b188e02514d05632c9b.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2016-09-26
@archakov06

I know this question has been asked for a long time, but maybe it will help someone. To get the $_GET array, it's something like this:

//для адреса http://site.ru/send/sms?phone=+7000000000
$app->get('/send/sms', function(Slim\Http\Request $request, Slim\Http\Response $response, $args){
        //$request->getQueryParams() - весь массив $_GET
  echo $request->getQueryParam('phone');

});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question