View Full Version : PHP reading outside its parent directory.

08-22-2011, 04:17 PM
I've got:


In index.html, I've got the following PHP code:

$files = glob('./*/*.listing');
foreach ($files as $file)
include $file;

As you can see, what PHP code does is include()'s all the index.listing files.

I then create a clone of the A directory and alter the HTML in the .listing files so can tell the difference between A & B when they render:


The issue I am having is "/B/index.html" is ()including the .listing files from the /A/*/ directory, when it should be including them from the /B/*/ directory.
I can't understand why this is happening and hoping someone could shed some light on the issue?

08-22-2011, 04:59 PM
I am not positive about this because I have never included files that way before. Does it have anything to do with the fact that you have two (*). Star means anything matching the criteria, the criteria being one folder forward for the first star. So I would think it would include A, B and C...but like I said, I have never included files that way. It is possible that it is just including the first thing matching the criteria, which would be the 'A' directory index. I am just guessing, but it is a somewhat educated guess.

08-22-2011, 05:04 PM
Hey dude,

Nah it couldn't be that reason because index.html is being execute inside the B directories. Thats what I don't understand... Its including files from a parent directory (A), when it should be including them from child directory /*/. Fully strange huh!

08-22-2011, 05:08 PM
I said index, but I meant *.listing. I think it is reading anything two folders forward that has a .listing file name. Does that change anything?

08-22-2011, 05:13 PM
No, index.html is being ran inside the A and B directories.

08-22-2011, 07:05 PM
Never mind, there was nothing wrong with the code. It was another problem. The code works.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum