PHP中的PHP_SELF,SCRIPT_NAME和REQUEST_URI有什么区别? [英] what's the difference between PHP_SELF, SCRIPT_NAME and REQUEST_URI in PHP?

查看:145
本文介绍了PHP中的PHP_SELF,SCRIPT_NAME和REQUEST_URI有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题中全部标明.

这三个属性之间有什么区别? 我一直在测试它们的价值,我只能说它们是相似的.但是,由于我是一个标准的怪胎,所以我想知道它们之间是否有些微妙之处,这样我就可以避免编码错误或以后被某些意料之外的行为所困扰.

What is the difference between the three properties ? I've been testing the value of them and all what I can say is they are similar. However because I'm a standard freak, I'd like to know if there are some subtlety between them so I can avoid bad coding or being stuck later in some unexpected behavior.

推荐答案

'PHP_SELF'

当前正在执行的脚本的文件名,相对于文档根目录.例如,位于地址为 http://example.com的脚本中的$ _SERVER ['PHP_SELF']/test.php/foo.bar 为/test.php/foo.bar. FILE 常量包含当前(即包含)文件的完整路径和文件名.如果PHP作为命令行处理器运行,则此变量包含自PHP 4.3.0起的脚本名称.以前它不可用.

The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar. The FILE constant contains the full path and filename of the current (i.e. included) file. If PHP is running as a command-line processor this variable contains the script name since PHP 4.3.0. Previously it was not available.

"SCRIPT_NAME"

'SCRIPT_NAME'

包含当前脚本的路径.这对于需要指向自己的页面很有用. FILE 常量包含当前(即包含)文件的完整路径和文件名.

Contains the current script's path. This is useful for pages which need to point to themselves. The FILE constant contains the full path and filename of the current (i.e. included) file.

'REQUEST_URI'

'REQUEST_URI'

为访问该页面而给出的URI;例如'/index.html'.

The URI which was given in order to access this page; for instance, '/index.html'.

这篇关于PHP中的PHP_SELF,SCRIPT_NAME和REQUEST_URI有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆