2

I have this function defined in a FileA.php

function readDirectory($aPath) {
    $list = Array();
    if(is_dir($aPath)) {
        if ($dh = opendir($aPath)) {
            while (($file = readdir($dh)) !== false) {
                if(is_file("$aPath/$file") && $file != '.htaccess') {
                    $list[$file] = "$file";
                }
            }
            closedir($dh);
        }
    }
    sort($list, SORT_STRING);
    return $list;
}

And I got FileA.php included() in FileB.php and then FileB.php included() in the FileC.php I want to execute. But I get:

Fatal error: Call to undefined function readDirectory() in ..folder/FileC.php on line 2

Can't figure out what's wrong.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
  • 2
    It's clearly not being included. Make sure your path to the files are correct in your includes. – naththedeveloper Mar 13 '14 at 11:39
  • 3
    try to use a 'require' instead of 'include'. 'require' will return an error if the file wasn't found (so we can check if the problem is that). Probably your files are in different directories so you need to control your includes path – Alberto Fecchi Mar 13 '14 at 11:39
  • Please show us how you are including the files and please [enable *full* error reporting](http://stackoverflow.com/questions/6575482/how-do-i-enable-error-reporting-in-php). – PeeHaa Mar 13 '14 at 11:49

1 Answers1

0

Instead of included() use include().

http://www.php.net/manual/ru/function.include.php

user2995220
  • 71
  • 1
  • 5