$_SERVER['SCRIPT_FILENAME']和__FILE__ 区别
$_SERVER['SCRIPT_FILENAME'] -------> 当前执行程序的绝对路径及文件名 __FILE__ -------> 原始文件(被包含文件)的绝对路径及文件名 eg: 假设web根目录是 e:/myweb 先建立 e:/myweb/index.php 内容是: <?php require 'other/index2.php'; ?> 再建立 e:/myweb/other/index2.php 内容是: <?php echo $_SERVER["SCRIPT_FILENAME"]; echo __FILE__; ?> 然后访问http://127.0.0.1/index.php,输出结果如下: E:/myweb/index.php -------------------当前执行程序的绝对路径及文件名 E:\myweb\other\index2.php -------------------原始文件(被包含文件)的绝对路径及文件名
posted on 2021-01-31 23:30 running-fly 阅读(94) 评论(0) 编辑 收藏 举报