如何在 php 中获取不同目录中的文件内容

How to get the contents of a file in a different directory in php

所以我有一个看起来像这样的文件系统:

-htdocs(parent folder)
  -html
    -footer.html
    -css
      -style.css
  -login
    -index.php
  -index.php

我想做的是从login/index.php中获取footer.html的内容。我环顾四周,但似乎找不到任何可以解决我的问题的东西。

如果重要的话,我正在使用 XAMPP 作为 Web 服务器。

你可以使用 ../html/footer.html。要转到 htdocs 文件夹,请使用两个点,然后移至页脚文件所在的 html 文件夹。