php - What's difference between different ways to get GET parameter in Controller-Action in Zend framework 2? -
i found several ways get
parameters inside controller > action in zend framework 2:
$this->params()->fromroute('id'); $this->params('id'); $this->getrequest()->getquery()->get('id');
is there difference among these ways?
i guess, params('id')
may give values get
, post
both. fromroute , getquery give value get
only, fromroute
may give advantages sanitation or something?
$this->params()->fromroute('id');
this uses params plugin , returns single named route parameter. used parameters in segment routes (e.g. 'slug' /blog/:slug
or 'year' /archive/:year/:month/:day
).
$this->params('id');
this shorthand $this->params()->fromroute('id');
.
$this->getrequest()->getquery()->get('id');
this grabs value query string.
Comments
Post a Comment