获取Kohana 3中的完整站点主页URL

Mar*_*rek 7 php kohana kohana-3

我安装了Kohana(在我的xampp公共文件夹中的"kohana"目录中),我正在尝试使用域和协议获取完整的基本URL.

当我尝试:

url::base();
Run Code Online (Sandbox Code Playgroud)

结果我只/kohana/回来了,但反而想要http://localhost/kohana/.

是否可以在Kohana中执行此操作,还是必须使用标准PHP?

sha*_*and 11

你不必扩展任何内容,只要使用URL::siteprotocol参数:

$base_url = URL::site(NULL, TRUE);
Run Code Online (Sandbox Code Playgroud)

这将生成具有当前协议的基本URL.如果要使用特定协议:

$base_url = URL::site(NULL, 'http');
Run Code Online (Sandbox Code Playgroud)

无需在这里重新发明轮子!