I have a script (let's call it a.php3) that brings in another script b.php3
with the include or require call.

In script b.php3 there is an include or require call to bring in script

Script a.php3 after making one and only one include (the include is not
repeated anywhere in a.php3) then calls a function x which is defined in
script b.php3.

The first time the function is called it executes without any problems. The
second time in which it is called, in exactly the same way, with the same
parameters, it errors with the message
Can't redeclare already declared function in c.php3 at line <the last line
of the first function declaration in c.php3>

The function is not actually named in the error message. This is the code
block in c.php3 which the error occurs:

<top of file>

 function getDirNames($sourceDir,$includeBase)
  global $pathList;

  function findAllDirsInDir($sourceDir)
   global $pathList;
   while (($subDir=readdir($dirHandle))!=false)
    if (is_dir($sourceDir."/".$subDir))
     if ($subDir != "." && $subDir != "..")
      $dirList[] = $sourceDir."/".$subDir;
      $pathList[] = $sourceDir."/".$subDir;
   return $dirList;
  }; <<error occurs here>>

  function buildDirList($sourceDir,$recurse)
   if (count($subDirList) != 0)
   for($i=0; $i<count($subDirList);$i++)
    if ($recurse==true)

  if ($includeBase == TRUE)
   $pathList[] = $sourceDir;
  return $pathList;

There are no multiple calls to include or require:

* a.php3 which is the script that calls the function several times to output
data, contains only one call to include() that is not inside any kind of
loop. It is called once just before the first function call.

*b.php3 which is the script that is included by a.php3. It includes c.php3

*c.php3 which is the script in which the error is occurring.

Debugging b.php3 shows that the error message is thrown when execution
reaches the line in which the function from c.php3 is called. Therefore I
surmise that the error message is ambiguous.

Reply via email to