PHP_SELF,SCRIPT_NAME,REQUEST_URI区别
《PHP_SELF,SCRIPT_NAME,REQUEST_URI区别》要点: $_SERVER[PHP_SELF],$_SERVER[SCRIPT_NAME],$_SERVER['REQUEST_URI'] 在用法上是非常相似的,他们返回的都是与当前正在使用的页面地址有关的信息,这里列出一些相关的例子,赞助确定哪些是在你的脚本最适合的.PHP实战 $_SERVER['PHP_SELF']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 当我们使用$_SERVER['PHP_SELF']的时候,无论拜访的URL地址是否有index.php,它都会自动的返回 index.php.但是如果在文件名后面再加斜线的话,就会把后面所有的内容都返回在$_SERVER['PHP_SELF'].PHP实战 $_SERVER['REQUEST_URI']PHP实战
代码如下:
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 $_SERVER['REQUEST_URI']返回的是我们在URL里写的准确的地址,如果URL只写到”/”,就返回 “/”PHP实战 $_SERVER['SCRIPT_NAME']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 ― C ― /example/index.php http://www.yoursite.com/example/index.php/dir/test ― C ― /example/index.php 在所有的返回中都是以后的文件名/example/index.phpPHP实战 《PHP_SELF,SCRIPT_NAME,REQUEST_URI区别》是否对您有启发,欢迎查看更多与《PHP_SELF,SCRIPT_NAME,REQUEST_URI区别》相关教程,学精学透。编程之家 52php.cn为您提供精彩教程。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |