This is a WordPress local installation that I am trying to work with. I have not written a single line of this code myself. I don’t understand what this error means:
Fatal error: Cannot redeclare class Config in /Applications/XAMPP/xamppfiles/lib/php/Config.php on line 44
Line 44 reads as follows:
class Config {
My guess is that a Config
class has either already been declared elsewhere, or that this file is being executed for the second time.
That usually happens when you declare a class more than once in a page — maybe via multiple includes.
To avoid this, use
require_once
instead. If you userequire_once
PHP will check if the file has already been included, and if so, not include (require) it again.Say, for example, you have the following code:
In this case, PHP will throw a fatal error similar to the one below:
In this case it’s very simple — simply find the 7th line of your code and remove the class declaration from there.
Alternativey, to make sure you don’t try to re-declare classes, you can use the handy
class_exists()
function:The best approach, of course, would be to organize all the configurations in one single file called
config.php
and thenrequire_once
it everywhere. That way, you can be sure that it will be included only once.As for debugging the error, you could use
debug_print_backtrace()
.It’s possible that the theme you are using refers to a file called config.php. If so use the following steps.