Jump to content

Can not get glob to work


maexus

Recommended Posts

Here is my directory structure

 

/projectname/

index.php

/lib/

-master.inc.php

-/includes/

--page.class.php

--cache.inc.php

 

What I want to do is include master.inc.php into index.php. master.inc.php will include all php files in the sub dir "includes". Here is the code I'm using.

 

<?php foreach(glob(realpath('includes')."/*.php") as $include){require_once $include;} ?>

 

Now, I try to envoke a new instance of the page class and says it's not found when used on index.php however when I invoke the page class directly in master.inc.php.. it works. I can change require_once $include to echo $include and it will echo out the file names and the directories they are in so I don't understand why it doesn't work in index.php Please help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.