$ _SERVER [' REQUEST_URI']和" $ _ SERVER [' REQUEST_URI']"之间有什么区别? (注意双引号)?

时间:2015-03-10 11:58:55

标签: php .htaccess

我在http://example.com/test/sub/index.php文件中有一些命令来回显php衍生值。 对于地址栏中的以下地址,我得到: http://example.com/test/sub/index.php/blahblah

$_SERVER[SCRIPT_NAME]: /test/sub/index.php

$_SERVER['HTTP_HOST']: example.com

$_SERVER['PHP_SELF']: /test/sub/index.php/blahblah

$_SERVER['REQUEST_URl']:

"$_SERVER['REQUEST_URI']": /test/sub/index.php/blahblah

为什么' REQUEST_URl'如果在没有引号的情况下使用,则返回null?

我正在尝试在.htaccess中调试我的RewriteRule,我需要' REQUEST_URl'返回路径为" /test/sub/index.php/blahblah"如果我能得到" index.php / blahblah"

它会更好

1 个答案:

答案 0 :(得分:2)

如果您想使用超级全局,请在大写中进行。例如,如果你真的想要返回FULL地址,你可以这样做:

$real_url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
相关问题