【问题标题】:how to include same file in different directory?如何在不同的目录中包含相同的文件?
【发布时间】:2014-11-08 18:01:45
【问题描述】:

目录结构:

主目录结构

     home.php 
     thankyou.php

php目录结构

     root directory/php/date.php

包括目录结构

     root directory/include/header.php
     root directory/include/footer.php

图片目录结构

      root directory/images/logo.png
      root directory/images/abc.jpg

对于 date.php,我想使用 header 和 footer.php 文件。但未显示图像。 我写在下面的代码

 <?php require_once '../include/header.php';?>

但是当我用于 home 和thankyou.php 时,它工作正常。

在头文件中,图片代码

<a href="index.php"><img src="images/logo.png" alt="Logo" class="image"></a>

我不想更改 date.php 的目录。 not interested to absolute path 用于图片。

如何在两个目录()中看到图像

【问题讨论】:

  • 你可以使用基本的 HTML 标签吗? w3schools.com/tags/tag_base.asp
  • @doubleui base tagabsolute path 相同
  • 也许为图像目录创建一个符号链接?如果您的文件系统支持。
  • @doubleui 如何创建符号链接?
  • 在 unix 上(不支持 Windows): ln -s root-directory/images root-directory/php/images 。在 wiki 上阅读更多信息:en.m.wikipedia.org/wiki/Symbolic_link

标签: linux .htaccess url path directory


【解决方案1】:

我使用了基本 html 标记,因为 doubleui 在头部告诉我

<head>
<base href="root directory/images/" target="_blank">
</head>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-04
    • 2019-06-07
    • 1970-01-01
    • 2011-08-23
    • 2014-01-05
    相关资源
    最近更新 更多