yii2經常使用路徑獲取

public function actionGetUrlList() { echo "當前域名地址:".Yii::$app->request->hostInfo."<br>"; echo "當前目錄物理路徑:".Yii::$app->basePath."<br>"; echo "當前項目路徑:".dirname(Yii::$app->BasePath)."<br>"; echo "當前Url: ".Yii::$app->request->url."<br>"; echo "當前Home Url: ".Yii::$app->homeUrl."<br>"; echo "當前return Url: ".Yii::$app->user->returnUrl."<br>"; echo "獲取當前模塊ID方法:".Yii::$app->controller->module->id."<br>"; echo "獲取當前控制器的ID方法:".Yii::$app->controller->id."<br>"; echo "獲取當前action的ID方法:".Yii::$app->controller->action->id."<br>"; echo "ip地址: ".Yii::$app->request->userIP."<br>";
echo "上一個絕對Url":".
Yii::$app->request->referrer."<br/>";
echo "返回絕對路徑:".
Yii::$app->urlManager->createAbsoluteUrl('a/b')."<br/>"
echo "是否啓用路由美化".Yii::$app->urlManager->enablePrettyUrl."<br/>";
}
相關文章
相關標籤/搜索