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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-04-22
  • 2022-01-10
  • 2021-12-22
  • 2021-05-25
  • 2022-12-23
猜你喜欢
  • 2022-01-07
  • 2021-07-15
  • 2021-08-16
  • 2022-12-23
  • 2022-03-01
相关资源
相似解决方案