Error "Fatal error: Can not redeclare (previously declared)" [closed]

1

I have a notification button where it shows the last requests that will come out on the system, I wanted to add the time it already left. Ex: 4 minutes ago, 1 hour ago, and when it was over 24 hours it showed 1 day ago, 2 days ago ..... I tried in several ways to shorten the times, but it can not. In my database I keep the following data:

  

record_date - > the day it was registered Ex: 2017-05-18;

     

schedule_register-> the time it was registered Eg: 10:19:30

function tempoCorridoDois($dataHoraString2) {
    $hoje2 = strtotime(date('Y/m/d H:i:s'));
    $dataHora2 = strtotime($dataHoraString2);
    $diferenca2 = $hoje2 - $dataHora2;

    $segundos2 = $diferenca2;
    $minutos2 = round($diferenca2 / 60);
    $horas2 = round($diferenca2 / 3600);
    $dias2 = round($diferenca2 / 86400);
    $semanas2 = round($diferenca2 / 604800);
    $meses2 = round($diferenca2 / 2419200);
    $anos2 = round($diferenca2 / 29030400);

    if ($segundos2 <= 60) {
      return "1 minuto atrás.";
    }else if ($minutos2 <= 60) {
      return  $minutos2 . ' minutos atrás.';
      }else if ($horas2 <= 24) {
        return $horas2 . ' horas atrás.';
        }else if ($dias2 <= 7) {
          return $dias2 . ' dia(s) atrás.';
          }else if ($semanas2 <= 4) {
            return $semanas2 . ' semanas atrás.';
            }else if ($meses2 <= 12) {
              return $meses2 . ' meses atrás.';
              }else{
                return $anos2 . ' anos atrás.';
              }
  }
      $tempoFinal2 = tempoCorridoDois($dataregistro2.$horarioregistro2);
  

And the following error appears:   Fatal error: Can not redeclare tiempoCorridoDois () (in C: \ xampp \ htdocs \ orders \ components \ php \ ff_notification 136

    
asked by anonymous 18.05.2017 / 15:21

2 answers

4
___ erkimt ___ Error "Fatal error: Can not redeclare (previously declared)" [closed] ______ qstntxt ___

I have a notification button where it shows the last requests that will come out on the system, I wanted to add the time it already left. Ex: 4 minutes ago, 1 hour ago, and when it was over 24 hours it showed 1 day ago, 2 days ago ..... I tried in several ways to shorten the times, but it can not. In my database I keep the following data:

  

record_date - > the day it was registered Ex: 2017-05-18;

     

schedule_register-> the time it was registered Eg: 10:19:30

 function tempoCorrido($dataHoraString) {
    $hoje = time();
    $dataHora = strtotime($dataHoraString);
    $diferenca = $hoje - $dataHora;

    $segundos = $diferenca;
    $minutos = round($diferenca / 60);
    $horas = round($diferenca / 3600);
    $dias = round($diferenca / 86400);
    $semanas = round($diferenca / 604800);
    $meses = round($diferenca / 2419200);
    $anos = round($diferenca / 29030400);

    if ($segundos <= 60) {
        return $segundos . " segundos atrás";
    } 
    else if ($minutos <= 60) {
        return  $minutos . 'min atrás';
    } 
    else if ($horas <= 24) {
        return $horas . ' hrs atrás';
    } 
    else if ($dias <= 7) {
        return $dias . ' dias atrás';
    } 
    else if ($semanas <= 4) {
        return $semanas . ' semanas atrás';
    } 
    else if ($meses <= 12) {
        return $meses . ' meses atrás';
    } 
    else {
        return $anos . ' anos atrás';
    }
}

echo tempoCorrido("2017-05-18 10:40:00");
  

And the following error appears:   Fatal error: Can not redeclare tiempoCorridoDois () (in C: \ xampp \ htdocs \ orders \ components \ php \ ff_notification 136

    
______ ___ azszpr205617

You can use the date_diff function () or manually do the same show below:

 function tempoCorrido($dataHoraString) {
    $hoje = time();
    $dataHora = strtotime($dataHoraString);
    $diferenca = $hoje - $dataHora;

    $segundos = $diferenca;
    $minutos = round($diferenca / 60);
    $horas = round($diferenca / 3600);
    $dias = round($diferenca / 86400);
    $semanas = round($diferenca / 604800);
    $meses = round($diferenca / 2419200);
    $anos = round($diferenca / 29030400);

    if ($segundos <= 60) {
        return $segundos . " segundos atrás";
    } 
    else if ($minutos <= 60) {
        return  $minutos . 'min atrás';
    } 
    else if ($horas <= 24) {
        return $horas . ' hrs atrás';
    } 
    else if ($dias <= 7) {
        return $dias . ' dias atrás';
    } 
    else if ($semanas <= 4) {
        return $semanas . ' semanas atrás';
    } 
    else if ($meses <= 12) {
        return $meses . ' meses atrás';
    } 
    else {
        return $anos . ' anos atrás';
    }
}

echo tempoCorrido("2017-05-18 10:40:00");
    
______ azszpr205634 ___

The error:

  

Fatal error: Can not redeclare tiempoCorridoDois () (previously declared in C: \ xampp \ htdocs \ orders \ components \ php \ ff_notificacao_php.php: 136) in C: \ xampp \ htdocs \ orders \ components \ php \ ff_notificacao_php. php on line 136

Indicates that the function has been declared twice, or you have realmenete declared twice or you must be using %code% (or %code% ) more than once in different files

To resolve change %code% or %code% to %code% or %code% , if not then check your scripts there should actually be two functions with the same name. p>

On "humanizing the hours", I recommend you try the solutions presented at:

___
18.05.2017 / 15:47
5

The error:

  

Fatal error: Can not redeclare tiempoCorridoDois () (previously declared in C: \ xampp \ htdocs \ orders \ components \ php \ ff_notificacao_php.php: 136) in C: \ xampp \ htdocs \ orders \ components \ php \ ff_notificacao_php. php on line 136

Indicates that the function has been declared twice, or you have realmenete declared twice or you must be using include (or require ) more than once in different files

To resolve change require or include to require_once or include_once , if not then check your scripts there should actually be two functions with the same name. p>

On "humanizing the hours", I recommend you try the solutions presented at:

18.05.2017 / 16:30