php 取服务器文档根路径
php教程 取服务器文档根路径
/**
* 取服务器文档根路径
* @return string
*/
function getRootPath() {
$sRealPath = realpath('./');
$sSelfPath = $_SERVER['PHP_SELF'];
$sSelfPath = substr( $sSelfPath, 0, strrpos( $sSelfPath, '/' ));
return substr($sRealPath, 0, strlen($sRealPath) - strlen($sSelfPath));
}
补充:Php教程,Php入门