Answer the question
In order to leave comments, you need to log in
How to get the current URL as an array in ZF2?
How to get the current URL in Zend 2 (only the controller, action and parameters are of interest) as an array? Or at least only parameters, as a string. It is necessary in order to compose the URL in the paginator, taking into account the parameter of the current page.
For example, from the url www.site.com/controler/action/param. Thanks
Answer the question
In order to leave comments, you need to log in
$uri = Zend\Uri\UriFactory::factory('http://example.com:80/my/path?a=b&c=d#token');
$scheme = $uri->getPath(); // "/my/path"
$scheme = $uri->getQuery(); // "a=b&c=d"
$scheme = $uri->getQueryAsArray();
// array(
// 'a' => 'b',
// 'c' => 'd',
// )
$scheme = $uri->getFragment(); // "token"
$controllerName =$this->params('controller');
$actionName = $this->params('action');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question