A
A
Alexander2016-05-10 11:38:25
PHP
Alexander, 2016-05-10 11:38:25

How to fix fatal error?

I'm trying to enable Jotcache on a Joomla site. Faced with the fact that when I try to exclude the module and the position of the basket from caching in the JotCache settings, the site simply crashes and displays the following error in the error.log.
PHP Fatal error: Cannot redeclare getEnding() (previously declared in C:\Windows\Temp\htmD867.tmp:10) in C:\Windows\Temp\htmD904.tmp on line 28
The module code is given below. Where is the error and how to fix it?

<?php
  $session = JFactory::getSession();
  $Goods = $session->get('Goods');
  $endingArray = array("услуга", "услуги", "услуг");
  if (count($Goods)!=0){
    echo ('<a href="/basket" class="basket">В корзине <span>'.count($Goods).'</span> <font>'.getEnding(count($Goods), $endingArray).'</font></a>');	
  }else{
    echo ('<a href="/basket" class="basket none">В корзине <span>0</span> <font>'.'</font></a>');	
}
  function getEnding($number, $endingArray)
  {
    $number = $number % 100;
    if ($number>=11 && $number<=19) {
      $ending=$endingArray[2];
    }
    else {
      $i = $number % 10;
      switch ($i)
      {
        case (1): $ending = $endingArray[0]; break;
        case (2):
        case (3):
        case (4): $ending = $endingArray[1]; break;
        default: $ending=$endingArray[2];
      }
    }
    return $ending;
  }
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2016-05-10
@aleksand44

You seem to be defining the getEnding function a second time.
As a quick fix, replace getEnding with getEnding1 in the function definition and call in this script.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question