zoukankan      html  css  js  c++  java
  • 【PHP】详解 $_SERVER 函数中QUERY_STRING和REQUEST_URI、SCRIPT_NAME、PHP_SELF区别

    实例:
    1、http://localhost/index.php/Home/Home/index.html 

    $_SERVER['QUERY_STRING'] = "";
    $_SERVER['REQUEST_URI']  = "/index.php/Home/H1/index.html";
    $_SERVER['SCRIPT_NAME'] = "/index.php";
    $_SERVER['PHP_SELF'] = "/index.php/Home/H1/index.html";

    2、http://localhost/index.php/Home/Home/index.html ?key=test (附带查询)
    结果:

    $_SERVER['QUERY_STRING'] = "key=test";
    $_SERVER['REQUEST_URI']  = "/index.php/Home/H1/index.html?key=test"; 
    $_SERVER['SCRIPT_NAME'] = "/index.php";
    $_SERVER['PHP_SELF'] = "/index.php/Home/H1/red.html";

    由实例可知:
    $_SERVER["QUERY_STRING"]  获取查询 语句,实例中可知,获取的是?后面的值
    $_SERVER["REQUEST_URI"]   获取 http://localhost 后面的值,包括/
    $_SERVER["SCRIPT_NAME"]   获取当前脚本的路径,如:index.php
    $_SERVER["PHP_SELF"]      当前正在执行脚本的文件名

    ————————————————

    努力追赶上那个曾被寄予厚望的自己


    ————————————————
  • 相关阅读:
    Permutations II
    Add Binary
    Integer to Roman
    Roman to Integer
    Word Break
    完整记录一则Oracle 11.2.0.4单实例打PSU补丁的过程
    SQL Tuning 基础概述06
    SQL Tuning 基础概述05
    SQL Tuning 基础概述04
    SQL Tuning 基础概述03
  • 原文地址:https://www.cnblogs.com/BearLee/p/7873795.html
Copyright © 2011-2022 走看看