zoukankan      html  css  js  c++  java
  • 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            -------------------原始文件(被包含文件)的绝对路径及文件名

  • 相关阅读:
    bzoj 4260REBXOR
    bzoj 1009GT考试
    cf 621E. Wet Shark and Blocks
    cf 507E. Breaking Good
    cf 766#
    bzoj 3732Network
    bzoj 4300绝世好题
    bzoj 4345[POI2016]Korale
    bzoj 4236JOIOJI
    bzoj 4237稻草人
  • 原文地址:https://www.cnblogs.com/macliu/p/12125117.html
Copyright © 2011-2022 走看看