国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PHP > 正文

PHP_SELF,SCRIPT_NAME,REQUEST_URI區(qū)別

2024-05-04 23:29:20
字體:
供稿:網(wǎng)友
這篇文章主要介紹了PHP_SELF,SCRIPT_NAME,REQUEST_URI區(qū)別,需要的朋友可以參考下
 
 

$_SERVER[PHP_SELF], $_SERVER[SCRIPT_NAME], $_SERVER['REQUEST_URI'] 在用法上是非常相似的,他們返回的都是與當前正在使用的頁面地址有關(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

 

當我們使用$_SERVER['PHP_SELF']的時候,無論訪問的URL地址是否有index.php,它都會自動的返回 index.php.但是如果在文件名后面再加斜線的話,就會把后面所有的內(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']返回的是我們在URL里寫的精確的地址,如果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

 

在所有的返回中都是當前的文件名/example/index.php


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 公安县| 新宁县| 藁城市| 镇江市| 无锡市| 肇源县| 鲁甸县| 宿松县| 左贡县| 高安市| 阳信县| 驻马店市| 澎湖县| 浪卡子县| 墨玉县| 乐平市| 应城市| 长兴县| 武清区| 安塞县| 弥勒县| 济源市| 小金县| 罗源县| 九江县| 广汉市| 商都县| 石屏县| 鲁山县| 革吉县| 精河县| 磐石市| 宝坻区| 莱阳市| 广元市| 乌苏市| 桐城市| 天长市| 长葛市| 湾仔区| 凤阳县|