PHP_SELF,SCRIPT_NAME,REQUEST_URI区别
php  /  管理员 发布于 7年前   173
$_SERVER[PHP_SELF], $_SERVER[SCRIPT_NAME], $_SERVER['REQUEST_URI'] 在用法上是非常相似的,他们返回的都是与当前正在使用的页面地址有关的信息,这里列出一些相关的例子,帮助确定哪些是在你的脚本最适合的。 $_SERVER['PHP_SELF'] 当我们使用$_SERVER['PHP_SELF']的时候,无论访问的URL地址是否有index.php,它都会自动的返回 index.php.但是如果在文件名后面再加斜线的话,就会把后面所有的内容都返回在$_SERVER['PHP_SELF']。 $_SERVER['REQUEST_URI'] $_SERVER['REQUEST_URI']返回的是我们在URL里写的精确的地址,如果URL只写到”/”,就返回 “/” $_SERVER['SCRIPT_NAME'] 在所有的返回中都是当前的文件名/example/index.php
http://www.yoursite.com/example/ ― C ― /example/index.php
http://www.yoursite.com/example/index.php ― C ― /example/index.php
http://www.yoursite.com/example/index.php?a=test ― C ― /example/index.php
http://www.yoursite.com/example/index.php/dir/test ― C ― /dir/test
http://www.yoursite.com/example/ ― C ― /
http://www.yoursite.com/example/index.php ― C ― /example/index.php
http://www.yoursite.com/example/index.php?a=test ― C ― /example/index.php?a=test
http://www.yoursite.com/example/index.php/dir/test ― C ― /example/index.php/dir/test
http://www.yoursite.com/example/ ― C ― /example/index.php
http://www.yoursite.com/example/index.php ― C ― /example/index.php
http://www.yoursite.com/example/index.php ― C ― /example/index.php
http://www.yoursite.com/example/index.php/dir/test ― C ― /example/index.php您可能感兴趣的文章:
上一条:
php实现无限级分类
下一条:
PHP扩展模块memcached长连接使用方法分析
122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号