0
I have an error inside a for loop. The Error gives me to the Function line.
$Valor = "SELECT max(id) FROM tb_empresa";
For ($contatador = 0; $contador = $Valor; $contador++){
//Código
function estaParaExpirar($data, $dias=10) {
if (!strtotime($data) || empty($data)) return false;
return(strtotime($data) < strtotime("+".$dias. "days") );
}
Fatal error: Cannot redeclare estaParaExpirar()
Okay, let’s go in parts: $contactor is spelled wrong. It’s $counter, and $counter = $Value should be $counter == $Value. If the function is Open() has its scope inside the loop, I recommend to put it outside and use only the call to it inside the is.
– Dalton Menezes
Just to explain what @Dalton quoted:
$contador = 0
you assign a value to the counter;$contador == 0
checks a simple equality where 0(integer) is equal to '0' (string);$contador === 0
checks an exact match in relation to the type where 0(integer) is different from '0' (string)– Papa Charlie
On the question, you NAY can declare more than one function with the same name
Cannot redeclare
. What would be the logic of having 2 identical functions?– Papa Charlie