• thinkphp5.0 获取URL信息


    获取URL信息

    $request = Request::instance();
    // 获取当前域名
    echo 'domain: ' . $request->domain() . '<br/>';
    // 获取当前入口文件
    echo 'file: ' . $request->baseFile() . '<br/>';
    // 获取当前URL地址 不含域名
    echo 'url: ' . $request->url() . '<br/>';
    // 获取包含域名的完整URL地址
    echo 'url with domain: ' . $request->url(true) . '<br/>';
    // 获取当前URL地址 不含QUERY_STRING
    echo 'url without query: ' . $request->baseUrl() . '<br/>';
    // 获取URL访问的ROOT地址
    echo 'root:' . $request->root() . '<br/>';
    // 获取URL访问的ROOT地址
    echo 'root with domain: ' . $request->root(true) . '<br/>';
    // 获取URL地址中的PATH_INFO信息
    echo 'pathinfo: ' . $request->pathinfo() . '<br/>';
    // 获取URL地址中的PATH_INFO信息 不含后缀
    echo 'pathinfo: ' . $request->path() . '<br/>';
    // 获取URL地址中的后缀信息
    echo 'ext: ' . $request->ext() . '<br/>';


    输出结果为:

    domain: http://tp5.com
    file: /index.php
    url: /index/index/hello.html?name=thinkphp
    url with domain: http://tp5.com/index/index/hello.html?name=thinkphp
    url without query: /index/index/hello.html
    root:
    root with domain: http://tp5.com
    pathinfo: index/index/hello.html
    pathinfo: index/index/hello
    ext: html
     
  • 相关阅读:
    文艺青年、普通青年、2b青年到底是什么意思?
    CMake快速入门教程:实战
    shell脚本中变量$$、$0等的含义
    工作上的C/C++相关
    C/C++的一些备忘
    shell基础二十篇 一些笔记
    C++中this指针的用法详解
    【C++11】新特性——auto的使用
    一个很不错的bash脚本编写教程
    容器
  • 原文地址:https://www.cnblogs.com/my2018/p/9128160.html
Copyright © 2020-2023  润新知