我用谷歌搜索它,但也许我的搜索关键字没用,所以如何在控制器中获取URL协议?是http://或https://
http://whatever.com/app_dev.php/welcome
//I need to echo http:// protocol here
echo $request->getHost(); //echos whatever.com
echo $request->getBaseUrl(); //echos app_dev.php/
Run Code Online (Sandbox Code Playgroud)
您可以在控制器中使用它:
$scheme = $this->getRequest()->getScheme();
Run Code Online (Sandbox Code Playgroud)
否则,这是一个代码,允许您知道服务器返回的所有值:
foreach ($_SERVER as $key => $value) {
echo $key.' => '.$value.'<br>';
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6685 次 |
| 最近记录: |