Okay I want to use the following function to include files into a script, but it seems the scope of the included variables only exists inside the function. Anyone got a way to make this work.
//-------------------------------------------------------------------
// Function parseDir
//
// parses a directory base on regular expression match of
// file name and includes all matching files
//
// filename must be of type filename.identifier.php
//
// baseDir is directory to parse
function parseDir($baseDir, $fileIdent) {
$dir = opendir($baseDir);
while ( $file = readdir( $dir ) ) {
$pregdef = "/^.*." . $fileIdent . ".php?/";
if ( preg_match($pregdef, $file ) ) {
include($baseDir.$file);
echo $file."<br />";
}
}
closedir($dir);
} // End parseDir
an example of intended usage
define("IN_APP", true);
include('includes/fileFunctions.php');
parseDir('./configs/', 'config');
where an include file is like
<?php
//-------------------------------------------------------------------
// Database Configuration File
//
//
if ( ! defined("IN_APP") ) {
die("HACKING ATTEMPT");
}
echo 'test';
$dbms = 'mysql';
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = 'webtemplate';
?>
named
db.config.php
Any Takers?
-Geoff