dprlv04662
2015-11-09 10:33
浏览 41
已采纳

如何包含主PHP文件所在文件夹之外的PHP文件?

This is my directory:

Wamp>www>Newlinks
  CSS (folder)
  header.php
  footer.php
    Profiles (folder)
      MainPHPfile.php

Now, I want to include the header and footer files into MainPHPfile.php, but it's not working. How to set the path so that it works?

Same problem is with CSS. I want to use CSS files from CSS folder for those header and footer files. Please solve this problem. I shall be thankful to you.

图片转代码服务由CSDN问答提供 功能建议

这是我的目录:

  Wamp> www> Newlinks  
 CSS(文件夹)
 header.php 
 footer.php 
配置文件(文件夹)
 MainPHPfile.php 
   
 
 

现在,我想要包括 页眉和页脚文件到MainPHPfile.php,但它不起作用。 如何设置路径以使其工作?

CSS也存在同样的问题。 我想使用CSS文件夹中的CSS文件作为页眉和页脚文件。 请解决这个问题。 我将感谢你。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • dsxd62219570 2015-11-09 10:34
    已采纳

    You could go a directory up with .. like this:

    <?php
    include '../header.php';
    include '../footer.php';
    

    Same with CSS.

    已采纳该答案
    打赏 评论
  • douxianji3367 2015-11-09 10:35

    In order to go up a folder, use the ../ relative path, if you need to go down a folder, just writte the relative continuous path. example/another_folder/file.php

    打赏 评论
  • dongshu9458 2015-11-09 10:51

    You can use ../path/folder/to/file.ext to go to the previous path. /path/folder/to/file.ext to go to the root of your website e.g /public-html/ or /htdocs/ .

    打赏 评论

相关推荐 更多相似问题