I am echoing the $indicator before $total using if else condition.
But I am getting php error
Notice: Undefined variable: indicator.
How I can achieve this without getting any error and get my result which will be yellow according to the if else condition. Is it possible?
<?php
$total=6;
echo $indicator;
echo $total;
if($total<5) {
$indicator="red";
} else if($total>7) {
$indicator="green";
} else {
$indicator="yellow";
}
?>
Aucun commentaire:
Enregistrer un commentaire