PHP 5.3 (an I think older versions too) seems to have problem with same name in different cases. So I had this problem when a had the class Login and the interface it implements LogIn. After I renamed LogIn to Log_In the problem got solved.
Call this function at the top of the file that includes your class.
Sometimes it will only print once, even though your class is being included two or more times. This is because PHP actually parses all the top-level classes in a file before executing any code and throws the fatal error immediately. To remedy this, wrap your class declaration in if(true) { ... }, which will move your class down a level in scope. Then you should get your two traces before PHP fatal errors.
This should help you find where you class is being included from multiple times in a complex project.
Use
include_once();
- with this, your codes will be included only one time.Just do one thing whenever you include or require filename namely class.login.php. You can include it this way:
This way it never throws an error.
It means you've already created a class.
For instance:
That second Foo would throw the error.
This error might also occur if you define the
__construct
method more than once.PHP 5.3 (an I think older versions too) seems to have problem with same name in different cases. So I had this problem when a had the class Login and the interface it implements LogIn. After I renamed LogIn to Log_In the problem got solved.
This function will print a stack telling you where it was called from:
Call this function at the top of the file that includes your class.
Sometimes it will only print once, even though your class is being included two or more times. This is because PHP actually parses all the top-level classes in a file before executing any code and throws the fatal error immediately. To remedy this, wrap your class declaration in
if(true) { ... }
, which will move your class down a level in scope. Then you should get your two traces before PHP fatal errors.This should help you find where you class is being included from multiple times in a complex project.