日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > php >内容正文

php

PHP_SELF、 SCRIPT_NAME、 REQUEST_URI区别

發(fā)布時(shí)間:2024/1/17 php 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PHP_SELF、 SCRIPT_NAME、 REQUEST_URI区别 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

$_SERVER[PHP_SELF], $_SERVER[SCRIPT_NAME], $_SERVER['REQUEST_URI'] 在用法上是非常相似的,他們返回的都是與當(dāng)前正在使用的頁面地址有關(guān)的信息,這里列出一些相關(guān)的例子,幫助確定哪些是在你的腳本最適合的。

$_SERVER[’PHP_SELF’]

  • http://www.yoursite.com/example/ — – —?/example/index.php
  • http://www.yoursite.com/example/index.php — – —?/example/index.php
  • http://www.yoursite.com/example/index.php?a=test — – —?/example/index.php
  • http://www.yoursite.com/example/index.php/dir/test — – —?/dir/test

當(dāng)我們使用$_SERVER['PHP_SELF']的時(shí)候,無論訪問的URL地址是否有index.php,它都會(huì)自動(dòng)的返回 index.php.但是如果在文件名后面再加斜線的話,就會(huì)把后面所有的內(nèi)容都返回在$_SERVER['PHP_SELF']。

$_SERVER['REQUEST_URI']

  • http://www.yoursite.com/example/ — – —?/
  • http://www.yoursite.com/example/index.php — – —?/example/index.php
  • http://www.yoursite.com/example/index.php?a=test — – —?/example/index.php?a=test
  • http://www.yoursite.com/example/index.php/dir/test — – —?/example/index.php/dir/test

$_SERVER['REQUEST_URI']返回的是我們?cè)赨RL里寫的精確的地址,如果URL只寫到”/”,就返回 “/”

$_SERVER['SCRIPT_NAME']

  • http://www.yoursite.com/example/ — – —?/example/index.php
  • http://www.yoursite.com/example/index.php — – —?/example/index.php
  • http://www.yoursite.com/example/index.php — – —?/example/index.php
  • http://www.yoursite.com/example/index.php/dir/test — – —?/example/index.php

在所有的返回中都是當(dāng)前的文件名/example/index.php

轉(zhuǎn)載于:https://www.cnblogs.com/zcy_soft/archive/2010/10/16/1853239.html

總結(jié)

以上是生活随笔為你收集整理的PHP_SELF、 SCRIPT_NAME、 REQUEST_URI区别的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。