【问题标题】:access core functions script from anywhere in domain?从域中的任何地方访问核心功能脚本?
【发布时间】:2011-09-20 17:46:23
【问题描述】:

我有一个coreFunctions.php 文件,其中包含我的大部分关键功能,我将它放在我域的根目录中。使用include(),我如何从位于较低目录中的脚本访问它?示例:我在http://domain.com/folder/index.php 中有一个脚本,您将如何从该脚本访问http://domain.com/coreFunctions.php

【问题讨论】:

  • 你应该把你的核心功能放在你域的根目录之外,这样访问错误就不会使你的代码对恶意第三方可见。

标签: php include root


【解决方案1】:
include("../coreFunctions.php");

【讨论】:

    【解决方案2】:
    include $_SERVER['DOCUMENT_ROOT'] . "/coreFunctions.php";
    

    【讨论】:

      【解决方案3】:

      我没有尝试过include,但尝试过require,我认为include 也应该适用于此。 只需使用 require "http://domain.com/coreFunctions.php";

      【讨论】:

        【解决方案4】:

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-02-27
          • 2013-03-06
          • 2020-06-22
          • 1970-01-01
          相关资源
          最近更新 更多