M
M
Maxim2016-09-21 16:49:25
symfony
Maxim, 2016-09-21 16:49:25

POST and GET parameters in framework at the same time?

I can’t understand how to get POST parameters, but how GET, if both are used at the same time.
I figured out only with the router, for both GET and POST to work, $app-> match () is needed at the same time;
It seems that frameworks should be so convenient, but here is a dead end.
Not really, you have to use $_GET and $_POST.

$app->post('/', function (Silex\Application $app) {
  $request = $app['request'];
  $ajax = $request->get('param'); //Это POST
});

$app->match('/', function (Silex\Application $app) {
  $request = $app['request'];
  $ajax = $request->get('param'); //Это GET
});

$app->match('/', function (Silex\Application $app) {
  $request = $app['request'];
  $ajax = $request->get('param'); //Это GET или POST?
});

I have SILEX, thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BoShurik, 2016-09-21
@brzsmg

https://symfony.com/doc/current/components/http_fo...

$app->match('/', function (Silex\Application $app) {
  $request = $app['request'];
  $ajax = $request->query->get('param'); //Это GET
  $ajax = $request->request->get('param'); //Это POST
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question