源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

PHP_SELF,SCRIPT_NAME,REQUEST_URI区别

  • 时间:2020-07-02 10:24 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:PHP_SELF,SCRIPT_NAME,REQUEST_URI区别
$_SERVER[PHP_SELF], $_SERVER[SCRIPT_NAME], $_SERVER['REQUEST_URI'] 在用法上是非常相似的,他们返回的都是与当前正在使用的页面地址有关的信息,这里列出一些相关的例子,帮助确定哪些是在你的脚本最适合的。 [b]$_SERVER['PHP_SELF'][/b]
[url=http://www.yoursite.com/example/]http://www.yoursite.com/example/[/url] — – — /example/index.php [url=http://www.yoursite.com/example/index.php]http://www.yoursite.com/example/index.php[/url] — – — /example/index.php [url=http://www.yoursite.com/example/index.php?a=test]http://www.yoursite.com/example/index.php?a=test[/url] — – — /example/index.php [url=http://www.yoursite.com/example/index.php/dir/test]http://www.yoursite.com/example/index.php/dir/test[/url] — – — /dir/test
当我们使用$_SERVER['PHP_SELF']的时候,无论访问的URL地址是否有index.php,它都会自动的返回 index.php.但是如果在文件名后面再加斜线的话,就会把后面所有的内容都返回在$_SERVER['PHP_SELF']。 [b]$_SERVER['REQUEST_URI'][/b]
[url=http://www.yoursite.com/example/]http://www.yoursite.com/example/[/url] — – — / [url=http://www.yoursite.com/example/index.php]http://www.yoursite.com/example/index.php[/url] — – — /example/index.php [url=http://www.yoursite.com/example/index.php?a=test]http://www.yoursite.com/example/index.php?a=test[/url] — – — /example/index.php?a=test [url=http://www.yoursite.com/example/index.php/dir/test]http://www.yoursite.com/example/index.php/dir/test[/url] — – — /example/index.php/dir/test
$_SERVER['REQUEST_URI']返回的是我们在URL里写的精确的地址,如果URL只写到”/”,就返回 “/” [b]$_SERVER['SCRIPT_NAME'][/b]
[url=http://www.yoursite.com/example/]http://www.yoursite.com/example/[/url] — – — /example/index.php [url=http://www.yoursite.com/example/index.php]http://www.yoursite.com/example/index.php[/url] — – — /example/index.php [url=http://www.yoursite.com/example/index.php]http://www.yoursite.com/example/index.php[/url] — – — /example/index.php [url=http://www.yoursite.com/example/index.php/dir/test]http://www.yoursite.com/example/index.php/dir/test[/url] — – — /example/index.php
在所有的返回中都是当前的文件名/example/index.php
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部