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