dongzhucha3999 2015-11-14 19:16
浏览 54

Php包括和文件夹

I’m creating a new site and in order to have the same navigation and footer in each page I created a footer and navigation files .

I put footer.php and navigation.php inside folder /include

this it the structure of my site so far:

old site folder

index.html  
other.html

New Site folder

/index.php
/biography.php
/style folder (style.css, responsive.css)
/images folder
/include folder (footer.php , navigation.php)
/media folder (videos.php)

the problems I have are with images included in footer and links within the navigation menu

for instance, on file biography.php I put on the footer area this calls the footer just fine but the images I have in the footer are broken (the images reside in the images folder) the same for navigation on biography.php, I have but the links in nav menu go back to old site folder, for instance index.php links to oldsite/index.php instead of newsite/index.php

the file videos.php footer and navigation display all ok , images and links

I guess the issue is with the paths, I tried adding / and dots but it doesn’t work

I don’t know what to do.. :(

  • 写回答

3条回答 默认 最新

  • douzi2749 2015-11-14 19:23
    关注

    you can include from your /include/footer.php with

    dirname(__FILE__).'/images/filetoinclude' 
    

    Edit:

    If you want to display images that are served by your webserver, you will have to specify either absolute path /images/images.jpg or the fully qualified path including its host as suggested above

    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号