亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

php中$_SERVER[PHP_SELF] 和 $_SERVER[SCRIPT_NAME]之間的區(qū)別

 更新時(shí)間:2009年09月05日 01:49:08   作者:  
php中$_SERVER[PHP_SELF] 和 $_SERVER[SCRIPT_NAME]之間的區(qū)別
“PHP_SELF”
當(dāng)前正在執(zhí)行腳本的文件名,與 document root 相關(guān)。舉例來(lái)說(shuō),在 URL 地址為 http://chabaoo.cn/test.php/foo.bar 的腳本中使用 $_SERVER['PHP_SELF'] 將會(huì)得到 /test.php/foo.bar 這個(gè)結(jié)果。__FILE__ 常量包含當(dāng)前(例如包含)文件的絕對(duì)路徑和文件名。

“SCRIPT_NAME”
包含當(dāng)前腳本的路徑。這在頁(yè)面需要指向自己時(shí)非常有用。__FILE__ 包含當(dāng)前文件的絕對(duì)路徑和文件名(例如包含文件)。

主要的原因如像:$_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];

找到更好的原因是:
今天在Dreamhost上安裝一套PHP程序時(shí)發(fā)現(xiàn)連接的地址都會(huì)多出一個(gè)cgi-system來(lái),但是程序的config並沒(méi)有問(wèn)題,查了查資料才發(fā)現(xiàn)是SCRIPT_NAME和PHP_SELF不同造成的問(wèn)題。
通常在本機(jī)測(cè)試 $_SERVER['SCRIPT_NAME'] 跟 $_SERVER['PHP_SELF'] 大概看不出有什麼不同,因?yàn)榇蟛糠值腜HP不是以CGI模式運(yùn)行的。
但 DreamHost 上的 PHP 是以 CGI 方式運(yùn)行,二者就有明顯不同的差異。
echo $_SERVER['SCRIPT_NAME']; // (/cgi-system/php.cgi)
echo $_SERVER['PHP_SELF']; // (/admin/test.php)

從http://lists.nyphp.org/pipermail/talk/2005-July/015339.html 發(fā)現(xiàn)了一個(gè)說(shuō)明。老外說(shuō)的。

SCRIPT_NAME solves all the problems mentioned
in this thread - it's just the script name, without any extra garbage
that might be tacked on by the user. PHP_SELF explicitly includes that
extra garbage, so solutions in this thread that involve stripping the
garbage off of PHP_SELF to make it safe are really, really missing the
point - just use SCRIPT_NAME instead. Please don't use FORM ACTION=”";
according to the spec, what the browser does with that is undefined, so
even if it works in current browsers, it might not work in future ones

相關(guān)文章

最新評(píng)論