function root(){
$root = $phpfile = '';
$iscgi = (0 === strpos(PHP_SAPI,'cgi') || false !== strpos(PHP_SAPI,'fcgi')) ? 1 : 0 ;
if ( $iscgi ) {
$temp = explode('.php',$_SERVER['PHP_SELF']);
$phpfile = rtrim(str_replace($_SERVER['HTTP_HOST'],'',$temp[0].'.php'),'/');
} else {
$phpfile = rtrim($_SERVER['SCRIPT_NAME'],'/');
}
$root = rtrim(dirname($phpfile),'/');
return (($root=='/' || $root=='\\') ? '' : $root);
}PS:在 tp3.2 复制下来的 