【问题标题】:php site root fundamentals on local server and online servers本地服务器和在线服务器上的 php 站点根基础
【发布时间】:2014-03-29 15:04:19
【问题描述】:

所以在花了很多时间弄清楚站点根之后,我决定问这个问题

我的网站有以下目录结构:

includes     //(contains db and other includes files)
public_html  //(this is the web -appication)

我想要的是包含这两个文件夹的目录的路径,而不是这些文件夹中的路径。

所以在包含目录中我有一个名为 initialize.php 的文件:

 defined('SITE_ROOT') ? null : define('SITE_ROOT',dirname(__FILE__));

这会在 wamp 上给出以下输出:

  C:\wamp\www\Mysite\includes\

在我得到的服务器上:

/home/a4554444/includes

我想要的是这个:

  C:\wamp\www\MySite\

我想删除最后列出的 \includes 文件夹,以便我可以使用该路径访问 public_html 文件夹并将其用于其他路径好吧

我该怎么做?

请以这种方式提及它是获取站点根目录的“正确”方式。如果没有提到正确的方法。

【问题讨论】:

    标签: php path directory-structure document-root


    【解决方案1】:

    也许您正在寻找类似的东西:

    define('serverpath', $_SERVER['DOCUMENT_ROOT']. '/');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-15
      • 2010-12-13
      • 2015-07-10
      • 2016-02-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-19
      • 2014-02-22
      相关资源
      最近更新 更多