php 区别: $_SERVER['SCRIPT_NAME'] 和 $_SERVER['PHP_SELF']
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6470748/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference between: $_SERVER['SCRIPT_NAME'] and $_SERVER['PHP_SELF']
提问by Jim
What is the difference between:
有什么区别:
$_SERVER['SCRIPT_NAME']
and
和
$_SERVER['PHP_SELF']
Thank you.
谢谢你。
回答by Michael Irigoyen
They should contain the same information. However, historically and technically speaking, there is a difference between the two.
它们应该包含相同的信息。但是,从历史和技术上讲,两者之间存在差异。
SCRIPT_NAME
is defined in the CGI 1.1 specification, and therefore is a standard. This means it should be available no matter what scripting language you're using.
SCRIPT_NAME
在 CGI 1.1 规范中定义,因此是一个标准。这意味着无论您使用哪种脚本语言,它都应该可用。
PHP_SELF
is implemented directly by PHP, and as long as you're programming in PHP, it will be there.
PHP_SELF
是直接用PHP实现的,只要你用PHP编程,它就在那里。
回答by regilero
Most of the time it's the same, but $_SERVER['SCRIPT_NAME']
is less spoofable than $_SERVER['PHP_SELF']
, so you should use SCRIPT_NAMEif you want to reuse that data somewhere on your output.
大多数情况下它是相同的,但$_SERVER['SCRIPT_NAME']
比 更不易被欺骗$_SERVER['PHP_SELF']
,因此如果您想在输出的某处重用该数据,则应使用SCRIPT_NAME。
Check that articleon different results obtained.
检查获得的不同结果的文章。