RE: [PHP] RE: help, weird include problem with functions
| From: | Jaxon | Date: | Thu, 09 Aug 2001 18:05:24 +0000 |
| Subject: | RE: [PHP] RE: help, weird include problem with functions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-62027@lists.php.net to get a copy of this message | ||
yes, I'm sure the directory exists :)
here is the actual code, I suppose this would have been more helpful to
start:
<?php
function incl_common()
{
global $modroot; //modroot is defined as http://localhost/modules in a
settings file
echo "<br>$modroot from included"; //this echos "http://localhost/modules"
properly
//the below throws the error, OpenDir: No such file or directory (error 2)
in (this function file name)
//but I can replce the $modroot/common with a hard-coded path and it works
fine.
$handle=opendir("$modroot/common");
while ($file = readdir($handle))
{ //load files in $directory into array
if ($file != ".." && $file != ".")
{
$files_to_include[count($files_to_include)] = $file;
}
}
//clean up and sort
closedir($handle);
if (is_array($files_to_include))
{
while (list ($key, $val) = each ($files_to_include))
{
include "$modroot/common/$val";
}
}
}
incl_common();
?>