$_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 -------------------原始文件(被包含文件)的絕對路徑及文件名