PHP $_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:mywebotherindex2.php            -------------------原始文件(被包含文件)的绝对路径及文件名

__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:mywebotherindex2.php            -------------------原始文件(被包含文件)的绝对路径及文件名