Cakephp3:如何在询问标记后使用get参数获取当前页面的完整URL

问题描述 投票:2回答:2

我正在努力获得完整的网址。在我的ctp文件中,我试过:

$this->Url->build(null, true)

要么

$this->request->here;

并尝试在Controller文件:

use Cake\Routing\Router;
Router::url(null, true)

但是在审讯标记之后,没有一个返回所有参数。

php cakephp cakephp-3.0
2个回答
1
投票

基于documentation,您可以获取当前请求URL,包括查询字符串参数,如下所示:

$this->request->here(false)

1
投票
use Cake\View\Helper\UrlHelper
$this->Url->build($this->request->here(), true);

要么

use Cake\Routing\Router
Router::url($this->request->here(), true);

两者在CTP文件上的工作方式相同

© www.soinside.com 2019 - 2024. All rights reserved.