Home  >  Article  >  php教程  >  ThinkPHP在CGI模式下的bug

ThinkPHP在CGI模式下的bug

WBOY
WBOYOriginal
2016-06-07 11:39:521035browse

ThinkPHP在CGI模式下的bug
php经验分享交流群:323899029
一般情况下$_SERVER['PHP_SELF'] 与 $_SERVER['SCRIPT_NAME'] 没有什么区别,但是如果PHP是以CGI模式运行的话两者就有差异

建议使用$_SERVER['SCRIPT_NAME'] ;

以下是有bug的代码(ThinkPHP/ThinkPHP.php第90行):
if(!IS_CLI) {
// 当前文件名
if(!defined('_PHP_FILE_')) {
if(IS_CGI) {
//CGI/FASTCGI模式下
$_temp = explode('.php',$_SERVER['SCRIPT_NAME']);//有问题,应该将$_SERVER['PHP_SELF']改成:$_SERVER['SCRIPT_NAME']
define('_PHP_FILE_', rtrim(str_replace($_SERVER['HTTP_HOST'],'',$_temp[0].'.php'),'/'));
}else {
define('_PHP_FILE_', rtrim($_SERVER['SCRIPT_NAME'],'/'));
}
}
if(!defined('')) {
$_root = rtrim(dirname(_PHP_FILE_),'/');
define('', (($_root=='/' || $_root=='\\')?'':$_root));
}
php经验分享交流群:323899029
转载自:http://www.phpskill.com

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn