dqd3690 2015-07-09 23:20
浏览 16

如何将相同的路由写入位于不同文件夹中的不同文件的文件

Imagine that I have following folders and files:

  • folder_a/
    • file_a.php
    • folder_a1
      • img_a1.png
    • folder_a2/
      • file_a2.php

Is there a way that I can write only one route to img_a1.png no matter if I am on file_a.php or file_a2.php?

This is what I'm doing now:

To access img_a1.png from file_a.php:

 <img src="folder_a1/img_a1.png"/>

To access img_a1.png from file_a2.php:

<img src="../folder_a1/img_a1.png"/>
  • 写回答

1条回答 默认 最新

  • dty5753 2015-07-09 23:46
    关注

    I don't understand your goals but, my answer may fit your requirement:

           define("IMG_DIR ","c://xampp/htdocs/project/folder_a/folder_a1/");
    

    now you just write your code like that :

    <img src="<?= IMG_DIR ;?>/img_a1.png">
    

    now you don't need to specify the directories in every php file that in different categories also

    I hope you can use this ^_^

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度