I use following simple code to include all files from common folder.
$path=array();
$ds=DIRECTORY_SEPARATOR;
$path['root']=$_SERVER['DOCUMENT_ROOT'];
$path['common']=$path['root'].$ds."common".$ds;
//Include settings
require $path['common'].$ds."settings.php";
//including common php files
foreach (glob($path['common'].$ds."*.php") as $filename) {
if($filename!="settings.php")
require $path['common'].$ds.$filename;
}
As you see, at first I use
require $path['common'].$ds."settings.php";
then including all the rest of files with foreach loop.
I wonder, if it is possible to include setting.php file first then all other files inside foreach loop, without writing line above?
1 Answer