首页 > 代码库 > 比较安全的获取站点更目录

比较安全的获取站点更目录

<?php
// 获取站点更目录,结尾不带 “\”
$root=isset($_SERVER[‘DOCUMENT_ROOT‘])?$_SERVER[‘DOCUMENT_ROOT‘]:(isset($_SERVER[‘APPL_PHYSICAL_PATH‘])?trim($_SERVER[‘APPL_PHYSICAL_PATH‘],"\\"):(isset($_[‘PATH_TRANSLATED‘])?str_replace($_SERVER["PHP_SELF"]):str_replace(str_replace("/","\\",isset($_SERVER["PHP_SELF"])?$_SERVER["PHP_SELF"]:(isset($_SERVER["URL"])?$_SERVER["URL"]:$_SERVER["SCRIPT_NAME"])),"",isset($_SERVER["PATH_TRANSLATED"])?$_SERVER["PATH_TRANSLATED"]:$_SERVER["SCRIPT_FILENAME"])));
echo $root;
?>