Re: [PHP] Re: Error: Can't redeclare already declared function (PHP 3.0.15)

2001-10-27 Thread ~~~i LeoNid ~~

On Sat, 27 Oct 2001 13:21:58 +0200 impersonator of [EMAIL PROTECTED]
(Tamas Arpad) planted &I saw in php.general:

>> Unfortunately, you can't include FUNCTION() conditionaly (well, you
>> can, but then you can't use it out of this if():). Why only such
>> dumn restriction, PHP developers?
>I think it's only true for php3
>
>I use many many class definitions in php4 that are inluded 
>conditionally in another classes' functions, and of course it works 
>fine.
>   Arpi
>
Hmm. Thats becoming interesting. Are you using 4.06 ? Becouse, i have this
version, and it doesn't give me such a chance. I thought it should, but
when tryed it proved otherwise..  Pss. I double-checked now on a simple example, 
and it worked as you say, it should.. But i re-member well that then i too checked 
several times.. Weird. (i must have missed s/t then or..) 
Anyway, 'll have in mind, that it should work, for the futer. Sorry 4 missleding & 
TnX. i.

-- 
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]




Re: [PHP] Re: Error: Can't redeclare already declared function (PHP 3.0.15)

2001-10-27 Thread Tamas Arpad

> Unfortunately, you can't include FUNCTION() conditionaly (well, you
> can, but then you can't use it out of this if():). Why only such
> dumn restriction, PHP developers?
I think it's only true for php3

I use many many class definitions in php4 that are inluded 
conditionally in another classes' functions, and of course it works 
fine.
Arpi


-- 
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]




Re: [PHP] Re: Error: Can't redeclare already declared function (PHP 3.0.15)

2001-10-27 Thread Kodrik

I include files in each other all the time, and some of them might call the 
same functions (like database functions).

I just use a string in all function declaration with the name of the 
functions or set of functions in the file.

if(!$function_test)
{
 $function_test=1;
 function test()
 {
  dfg
  fdggfdg
  fdg
 }
}

This way you can include the same functions many times without error.


-- 
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]




Re: [PHP] Re: Error: Can't redeclare already declared function (PHP 3.0.15)

2001-10-27 Thread ~~~i LeoNid ~~

On Fri, 26 Oct 2001 20:54:00 -0400 impersonator of [EMAIL PROTECTED]
(Gerard Onorato) planted &I saw in php.general:

>Hi,
>
>Another solution I have used when I have to do conditional includes which
>may cause the same page to be included twice
>
Unfortunately, you can't include FUNCTION() conditionaly (well, you can,
but then you can't use it out of this if():). Why only such dumn
restriction, PHP developers?
>
>At the top of the code to be included (the separate file) put something
>like:
>
>if ($theFileAlreadyInclude != 1) {
>
Right. That what i do too, but you include _code_ (whithout functions:()
in that case..
--
i

-- 
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]




RE: [PHP] Re: Error: Can't redeclare already declared function (PHP 3.0.15)

2001-10-26 Thread Gerard Onorato

Hi,

Another solution I have used when I have to do conditional includes which
may cause the same page to be included twice


At the top of the code to be included (the separate file) put something
like:

if ($theFileAlreadyInclude != 1) {

and at the bottom you may put:

}
$theFileAlreadyIncluded =1;

depending on the way your coding you may need make the variable global.

Hope this helps.

Gerard




-Original Message-
From: Jason Wood [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 26, 2001 3:43 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Error: Can't redeclare already declared function (PHP
3.0.15)


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
www.expressivetek.com



"Patrick Dunford" <[EMAIL PROTECTED]> wrote in message
001501c15e27$1a738b80$bd84a7cb@patricks">news:001501c15e27$1a738b80$bd84a7cb@patricks...
> 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
> 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.
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  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:
>
> 
> 
>  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;
>   }; <>
>
>   function buildDirList($sourceDir,$recurse)
>   {
>$subDirList=findAllDirsInDir($sourceDir);
>if (count($subDirList) != 0)
> $recurse=true;
>else
> $recurse=false;
>for($i=0; $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
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
> ONCE ONLY, NOT IN A LOOP.
>
> *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]


-- 
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]