It's probably not caused by PHP but by the way you include files.
Assume we have:
PHP file "top.inc" located in root folder containing:
<div>
This is top of page with some image: <img src="some_image.gif" />
</div>
File "some_image.gif" is also located in root folder.
In the same (root) folder we have also "index.php" file containing:
<html>
<body>
<?php
include( 'top.inc' );
?>
<div>
This is a main page.
</div>
</body>
</html>
This file will display the image properly. But if we also have
subfolder called "sub" containing "index.php" file with:
<html>
<body>
<?php
include( '../top.inc' );
?>
<div>
This is a subpage.
</div>
</body>
</html>
Then the "sub/index.php" will not display the image properly
cause image tag contains relative path to "some_image.gif"
which is now relative to "sub" folder (from which we called
"index.php"). The fact that "top.inc" file is in root folder
is irrelevant here.
You'll have similar problem if the "top.inc" and "some_image.gif"
were located in "sub" folder but included in PHP file called
from root folder.
When you use relative paths in PHP, you have to consider
where your files are located and where from they are included.
All relative URLs (<a href>, <img src>, <script src> etc.) given
in output HTML will be considered relative to the path of file
which was initially called (the browser has no idea that
some URLs were generated by files included from subfolders).
Another cause could be wrapping URL parameters as fragments
of path, eg.:
http://some.domain.com/some_path/some_scri...p/param1/param2In this case "some_script.php" in "some_path" is generating
output HTML, but all URLs will be relative to virtual path
http://some.domain.com/some_path/some_scri...p/param1/param2In the example above the easiest solution would be to change
relative path to the image file to server absolute path
(you do not have to provide Internet absolute path, which
means including protocol name and server name):
<img src="/some_image.gif" />
or (in the second case):
<img src="/sub/some_image.gif" />
It'll also work in case of path-wrapped parameters.
Hilarion