设为首页
收藏本站
用户名
Email
自动登录
找回密码
密码
登录
立即注册
只需一步,快速开始
快捷导航
登录
注册
论坛首页
BBS
建站模版
微站设计
虚拟主机
企业邮箱
博客日志
Blog
搜索
搜索
搜索
热搜
长春
优惠
活动
做网站
本版
帖子
用户
本版
帖子
用户
请
登录
后使用快捷导航
没有帐号?
立即注册
道具
勋章
任务
留言板
设置
我的收藏
退出
时时商务社区
»
论坛首页
›
建站资源
›
建站技术
›
PHP_SELF,SCRIPT_NAME,REQUEST_URI区别
返回列表
查看:
1522
|
回复:
0
PHP_SELF,SCRIPT_NAME,REQUEST_URI区别
[复制链接]
yj1281
当前离线
积分
7391
2487
主题
2487
帖子
7391
积分
论坛元老
论坛元老, 积分 7391, 距离下一级还需 9992608 积分
论坛元老, 积分 7391, 距离下一级还需 9992608 积分
积分
7391
发消息
电梯直达
楼主
发表于 2018-2-14 05:51:04
|
只看该作者
|
倒序浏览
|
阅读模式
$_SERVER[PHP_SELF], $_SERVER[SCRIPT_NAME], $_SERVER['REQUEST_URI'] 在用法上是非常相似的,他们返回的都是与当前正在使用的页面地址有关的信息,这里列出一些相关的例子,帮助确定哪些是在你的脚本最适合的。
$_SERVER['PHP_SELF']
[U]复制代码[/U] 代码如下:
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.但是如果在文件名后面再加斜线的话,就会把后面所有的内容都返回在$_SERVER['PHP_SELF']。
$_SERVER['REQUEST_URI']
[U]复制代码[/U] 代码如下:
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']
[U]复制代码[/U] 代码如下:
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
您可能感兴趣的文章:
php中$_SERVER[PHP_SELF] 和 $_SERVER[SCRIPT_NAME]之间的区别
不要轻信 PHP_SELF的安全问题
php self,$this,const,static,->的使用
php $_SERVER["REQUEST_URI"]获取值的通用解决方法
深入php self与$this的详解
Apache Request-URI Too Large错误解决方法
分享到:
QQ好友和群
QQ空间
腾讯微博
腾讯朋友
收藏
0
回复
使用道具
举报
返回列表
高级模式
B
Color
Image
Link
Quote
Code
Smilies
您需要登录后才可以回帖
登录
|
立即注册
本版积分规则
发表回复
回帖后跳转到最后一页
用户反馈
客户端