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

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -