Page 1 of 1

Multipli call to a function

Posted: Tue Jan 11, 2005 8:46 am
by Hagar
I get this error when I call the same function twice from a class that has an include of the class mentioned below:

Fatal error: Cannot redeclare class scripts in C:\PHP\includes\Class\Select\scripts.php on line 2

Posted: Tue Jan 11, 2005 8:53 am
by jason
Yes, it pretty much tells you the error. Basically, you are including a file twice that contains a class that already exists.

Using include_once instead of include to solve this problem.

Posted: Wed Jan 12, 2005 1:25 am
by Hagar
Yes I have tried it then I get the following error:

Fatal error: Class 'scripts' not found in C:\PHP\includes\Class\Select\results.php on line 16

Because it was include before the second time you call it, it doesn't request it another time thus PHP can not re-instantiate

Code: Select all

class Script
if that makes any sense.

Posted: Wed Jan 12, 2005 1:47 am
by feyd
if you're calling this class definition inside a function, move it outside the function.