<?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;
?>
比较安全的获取站点更目录
时间: 2024-10-13 02:12:19