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

ThinkPHP在CGI模式下的bug

WBOY
Release: 2016-06-07 11:39:52
Original
1072 people have browsed it

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元

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template