Cannot redeclare <func-name> in UDT

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
User avatar
hibr
Forum Members
Forum Members
Posts: 73
Joined: Fri Feb 08, 2008 11:22 pm

Cannot redeclare <func-name> in UDT

Post 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
Hanis Sammelsurium - How To's, Erfahrungs- und Meinungsberichte
Post Reply

Return to “Developers Discussion”