Hello,
I'm getting the error: "Fatal error: Cannot redeclare class session in..." because I am declaring the class session twice, in different files. Is there a way to allow it to be declared twice?
Thanks
Declare Class Twice
Moderator: General Moderators
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Declare Class Twice
No you cannot declare the same class twice...
use include_once to prevent the same class file from being included twice or re-work your code to fix this design problem.
use include_once to prevent the same class file from being included twice or re-work your code to fix this design problem.
Re: Declare Class Twice
Code: Select all
if (!class_exists('USER'))
{
class USER
{
var $name;
var $age;
function USER()
{
}
}
} // end if not class_exists
Re: Declare Class Twice
use require_once. You want an error to be thrown so if you mess up your code you won't keep moving forward blindly with bugs.