View Full Version : php include pics + html/folder from seperate folder.

08-22-2007, 02:28 AM
I know how to use the php include funtion, but it only seems to work in the same folder, or from a folder to sub-folder. I was wondering if there is a way to do these things, as it would make my website a lot easier to maintain.
Is there a way I can include pictures, or folders that include pictures? Can I include a folder of items? Can I include " html_root/home/folder/header.php" in "html_root/mypage/folder/index.php"?



08-22-2007, 02:56 AM

A real example:

<title>Example Page</title>
<div id="header">

As for including folders, no, it's not possible. Or at least to my knowledge it isn't. Although I suppose you can include a file in an included file, I don't see anything that could go wrong with that.

08-22-2007, 03:10 AM
I have never tried including images, only include scripted files. I just echo the images, not include.

Including stuff in different folders is easy, you just need to backup the script. each perdiod (.) includes 1 backup. so to include home/header.php in home/stuff/morestuff/index.php, you would use "../header.php"

And as far as including folders, I am pretty sure you can find yourself a nice snippet (or code) that will echo the files in a folder, and then just include that snippet. (its called directory handle)

08-22-2007, 04:17 AM
That's not entirely true, Erin. To "backup" directories you use two periods per directory(../images/etc.jpg); One period points to the current directory(./etc.jpg). fl00d was right about the full paths though, those should work. Just make sure you always start it with a backslash on linux.