Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Banned
    Join Date
    Aug 2011
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    PHP reading outside its parent directory.

    I've got:
    /A/index.html
    /A/1/index.listing
    /A/2/index.listing
    /A/3/index.listing
    In index.html, I've got the following PHP code:
    <?php
    $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:
    /B/index.html
    /B/1/index.listing
    /B/2/index.listing
    /B/3/index.listing
    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?
    Last edited by Kolusion; 08-22-2011 at 04:39 PM.

  • #2
    New Coder
    Join Date
    Jan 2010
    Location
    Birmingham, MI
    Posts
    98
    Thanks
    3
    Thanked 9 Times in 9 Posts
    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.

  • #3
    Banned
    Join Date
    Aug 2011
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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!

  • #4
    New Coder
    Join Date
    Jan 2010
    Location
    Birmingham, MI
    Posts
    98
    Thanks
    3
    Thanked 9 Times in 9 Posts
    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?

  • Users who have thanked JamesOxford for this post:

    Kolusion (08-22-2011)

  • #5
    Banned
    Join Date
    Aug 2011
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts
    No, index.html is being ran inside the A and B directories.
    Last edited by Kolusion; 08-22-2011 at 05:17 PM.

  • #6
    Banned
    Join Date
    Aug 2011
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Never mind, there was nothing wrong with the code. It was another problem. The code works.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •