Page 1 of 1

Cannot redeclare <func-name> in UDT

Posted: Thu Jul 03, 2008 4:38 pm
by hibr
Hi,

First I am a very less expierenced in PHP programming. My "problem":

I developed a UDT which contains a function. When I call the UDT more than once on a page I get "Cannot redeclare ". I guess the function is included more than once. include_once() or require_once() should solve the problem but I do not want and have not the knowledge to alter the core files.

I used a workaround like:

Code: Select all

if (!function_exists("<func-name>")){
   function <func-name>($parameter){
      ....
    return $result;
    }
}
That is ok if you have only one function but ....
Is there a more elegant way to solve the problem? Thankx.

Hani