如何获取 Cakephp 的完整当前 url

2021-12-21 00:00:00 php cakephp

如何在 Cake 的视图中回显当前 URL?

How do you echo out current URL in Cake's view?

推荐答案

你可以做任何一个

来自视图文件:

<?php echo $this->request->here() ?>">

哪个会给你来自主机名的绝对网址,即/controller/action/params

Which will give you the absolute url from the hostname i.e. /controller/action/params

<?php echo Router::url(null, true) ?> 

它应该为您提供带有主机名的完整网址.

which should give you the full url with the hostname.

相关文章