Home > Backend Development > PHP Tutorial > PHP include文件时的路径疑问解决思路

PHP include文件时的路径疑问解决思路

WBOY
Release: 2016-06-13 10:05:32
Original
858 people have browsed it

PHP include文件时的路径疑问
大家好,我在开发PHP时遇到个问题,希望大家能帮我一下,谢谢。
我在根目录下有1个文件sports.php和2个文件夹images,include。
images文件夹下有个文件back.gif,
include文件夹下有个head.html,其中插入了back.gif图片PHP include文件时的路径疑问解决思路.。
这时我打开head.html,一切正常。
但是问题是,我sports.php有句代码是
这时启动apache打开soccer.php,图片出不来了,
请问在不改变文件路径的前提下这个问题该怎么解决呢?

------解决方案--------------------
目录结构 
images
back.gif
include
head.html
sports.php

当你把文件include进来后
sports.php 的内容为
……
PHP include文件时的路径疑问解决思路 
……
但相对于 sports.php back.gif的路径为 ./images/back.gif,不是 ../images/back.gif
../表示 sports.php所在目录的上一级目录了

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template