PHP_SELF、 SCRIPT_NAME、 REQUEST_URI区别
2015-07-10 09:41
671 查看
$_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.但是如果在文件名后面再加斜线的话,就会把后面所有的内容都返回在$_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
相关文章推荐
- Build error handing
- codeforce 3D. Least Cost Bracket Sequence(贪心)
- [视频]Win10 Build 10166串流Xbox One游戏演示:赞的没话说
- webpack: require.ensure与require AMD的区别
- Errors occurred during the build
- 使用UIButton
- 使用UIButton
- UGUI 实现界面 渐隐渐现 FadeIn/Out 效果
- 使用UIAlertView
- 使用UIAlertView
- 使用UIActionSheet
- 使用UIActionSheet
- 如何判断NGUI的ScrollView是否正在移动
- Win10 Build 10166 加入Wi-Fi购买 随时随地连Wi-Fi、不断网
- could not build module ‘Foundation’, could not build module ‘UIKit’……23个错误
- could not build module ‘Foundation’, could not build module ‘UIKit’……23个错误
- Windows 10 Build 10166正式推送 允许购买wifi
- Windows 10 Build 10166发布 Groove品牌正式上线
- pkg: cached package *:size mismatch, cannot continue
- iOS中UILabel 多行显示