Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我安装了 Kohana(在我的 xampp 公用文件夹中的“kohana”目录中),我正在尝试使用域和协议获取完整的基本 URL。
当我尝试:
url::base();
结果我只/kohana/回来了,而是想要http://localhost/kohana/。
/kohana/
http://localhost/kohana/
是否可以在 Kohana 中执行此操作,或者我必须使用标准 PHP?
您不必扩展任何东西,只需URL::site与protocol参数一起使用:
URL::site
protocol
$base_url = URL::site(NULL, TRUE);
这将使用当前协议生成一个基本 URL。如果要使用特定协议:
$base_url = URL::site(NULL, 'http');
无需在这里重新发明轮子!