请求URLs

  • url:返回 /admin/index.php/product?id=100, 此URL不包括host info部分。
  • absoluteUrl:返回 http://example.com/admin/index.php/product?id=100, 包含host infode的整个URL。
  • hostInfo:返回 http://example.com, 只有host info部分。
  • pathInfo:返回 /product, 这个是入口脚本之后,问号之前(查询字符串)的部分。
  • queryString:返回 id=100,问号之后的部分。
  • baseUrl:返回 /admin, host info之后, 入口脚本之前的部分。
  • scriptUrl:返回 /admin/index.php, 没有path info和查询字符串部分。
  • serverName:返回 example.com, URL中的host name。
  • serverPort:返回 80, 这是web服务中使用的端口。
  •        

  • $headers = Yii::$app->request->headers;

    // 返回 Accept header 值
    $accept = $headers->get('Accept');

猜你喜欢

转载自blog.csdn.net/xiaoyangxiaodong/article/details/81258102