Another possible culprit is source control and unresolved conflicts. SVN may cause the same class to appear twice in the conflicted code file; two alternative versions of it ("mine" and "theirs").
I had the same problem "PHP Fatal error: Cannot redeclare class XYZ.php".
I have two directories like controller and model and I uploaded by mistakenly XYZ.php in both directories.(so file with the same name cause the issue).
First solution:
Find in your whole project and make sure you have only one class XYZ.php.
Second solution:
Add a namespace in your class so you can use the same class name.
Just adding;
This error can also occur if you by mistake put a function inside another function.
Another possible culprit is source control and unresolved conflicts. SVN may cause the same class to appear twice in the conflicted code file; two alternative versions of it ("mine" and "theirs").
I had the same problem while using
autoload
like follows:and in other class there was:
The sollution is to keep namespace compatibility, in my example
namespace testClassNamespace;
in both files.Did You use Zend Framework? I have the same problem too.
I solved it by commenting out this the following line in
config/application.ini
:I hope this will help you.
I had the same problem "PHP Fatal error: Cannot redeclare class XYZ.php".
I have two directories like
controller
andmodel
and I uploaded by mistakenly XYZ.php in both directories.(so file with the same name cause the issue).First solution:
Find in your whole project and make sure you have only one class XYZ.php.
Second solution:
Add a namespace in your class so you can use the same class name.
Sometimes that happens due to some bugs in PHP's FastCGI.
Try to restart it. At Ubuntu it's: