ThinkPHP bug in CGI Mode

Source: Internet
Author: User
Tags rtrim
Provides various official and user-released code examples. For code reference, you are welcome to discuss ThinkPHP bug in CGI Mode.
Php experience sharing group: 323899029
In general, $ _ SERVER ['php _ SELF '] is no different from $ _ SERVER ['script _ name']. However, if PHP runs in CGI Mode, the two are different.

We recommend that you use $ _ SERVER ['script _ name'];

The following is the code with a bug (ThinkPHP/ThinkPHP. php line 90th ):
If (! IS_CLI ){
// Current file name
If (! Defined ('_ PHP_FILE _')){
If (IS_CGI ){
// CGI/FASTCGI Mode
$ _ Temp = explode ('. php ', $ _ SERVER ['script _ name']); // if there is a problem, change $ _ 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 experience sharing group: 323899029
Reprinted from: http://www.phpskill.com

AD: truly free, domain name + VM + enterprise mailbox = 0 RMB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.