Mistake:

Error: Cannot redeclare CheckEvenOdd () (previously declared D: \ OpenServer \ domains \ localhost \ functions.php: 2) in D: \ OpenServer \ domains \ localhost \ functions.php on line 8

function CheckEvenOdd($value) { if(($value%2) == 0) { return 'even'; } else { return 'odd'; } } 

How to fix? Nowhere is the function set anymore. It is called like this:

 $week = CheckEvenOdd(date('W')); if($week == 'even') { $above = ' class="active"'; $below = ''; } elseif($week == 'odd') { $below = ' class="active"'; $above = ''; } 
  • What is on the second line of the functions.php file? - LEQADA
  • The second specifies the function, 8 brackets closing functions - iSize1ce

1 answer 1

You somehow connect the file with this function twice, so during the second pass the interpreter tries to re-declare it, which leads to the above error. If you have custom autoloaders, check them first; If this is not the case, make sure that you do not connect the file twice or that it does not connect in a loop.