如何在 ZF 1.12 中获取 http 主机

Paw*_*dło 0 php zend-framework http-host

如何获取主机地址?例如,我的网站位于此处:http://example.org/index/news/ 我只想提取http://example.org/

我想问一下ZF功能。我知道 $_SERVER['HTTP_HOST'] 但我正在寻找原生的东西。

Tim*_*ain 5

从控制器:

$this->getRequest()->getServer('HTTP_HOST')
Run Code Online (Sandbox Code Playgroud)

这会给你example.org,剩下的你必须在它周围添加。