I had the same type of problem. ( i think)

I had one main page (say index.php) that had a bare bones html page.  No
functions or anything.
Then i had separate pages that would be included only if i was using them
(like, say, a category.php for displaying categories, then products.php for
showing products.)

I had a function called printlist();  that would create a drop down menu
with categories/subcategories;  this was in both category.php and
products.php.  Niether of those files were included at the same time though,
and it'd give me the redeclare error... what i did was rename the function
in each file (like for category.php, rename it to printlist1(); and then in
products.php rename it to printlist2();... this is a quick fix).  Let me
know if this was any help :)

Jason Wood
Chief Technology Officer
Expressive Tek, Inc.
407 Kehrs Mill Road
Ballwin, MO 63011
Phone 636.256.1362

"Patrick Dunford" <[EMAIL PROTECTED]> wrote in message
> I have a script (let's call it a.php3) that brings in another script
> with the include or require call.
> In script b.php3 there is an include or require call to bring in script
> c.php3.
> 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.
> 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>
> <?php
>  function getDirNames($sourceDir,$includeBase)
>  {
>   global $pathList;
>   function findAllDirsInDir($sourceDir)
>   {
>    global $pathList;
>    $dirHandle=opendir($sourceDir);
>    while (($subDir=readdir($dirHandle))!=false)
>    {
>     if (is_dir($sourceDir."/".$subDir))
>     {
>      if ($subDir != "." && $subDir != "..")
>      {
>       $dirList[] = $sourceDir."/".$subDir;
>       $pathList[] = $sourceDir."/".$subDir;
>      }
>     }
>    }
>    closedir($dirHandle);
>    return $dirList;
>   }; <<error occurs here>>
>   function buildDirList($sourceDir,$recurse)
>   {
>    $subDirList=findAllDirsInDir($sourceDir);
>    if (count($subDirList) != 0)
>     $recurse=true;
>    else
>     $recurse=false;
>    for($i=0; $i<count($subDirList);$i++)
>    {
>     $currentSubDir=$subDirList[$i];
>     if ($recurse==true)
>      buildDirList($currentSubDir,$recurse);
>    }
>   }
>   buildDirList($sourceDir,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
> 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.

PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to