I have an includes file with a few class files in:
|includes
|-> database.class.php
|-> user.class.php
|-> functions.php
etc.. Inside my functions.php I include all the class files:
include_once 'database.class.php';
I want to separate some standard files from the class files by changing the structure to:
|includes
|-> functions.php
|-> class
|-> database.class.php
|-> user.class.php
Thus when I attempt to use glob
:
foreach (glob('/class/*.class.php', GLOB_NOCHECK) as $filename) {
include_once $filename;
}
I get the following error:
Warning: include_once(/class/*.class.php): failed to open stream: No such file or directory in /home/matt500b/dev2.csgoberry.com/includes/functions.php on line 13
I have to change it to:
glob('../../includes/class/*.class.php', GLOB_NOCHECK)
I want to understand the reason for this when I can just do include_once 'class/database.class.php';
normally.
Why does glob depend on the file that a user is look at rather than including from the functions file as per the manual including? e.g. if I go deeper into a file structure:
|public
|-> tournament
|-> dir2
|-> index.php
I need to use glob('../../../includes/class/*.class.php', GLOB_NOCHECK)
The functions.php file is included in my index.php file using include '../../includes/functions.php';
Total file structure:
|includes
|-> database.class.php
|-> user.class.php
|-> functions.php
|public
|-> tournament
|-> index.php // Where the ../../includes/functions.php'; is