Good, what you tried to do is calculate the performance depending on sales and visits, for which I do the following: $total_rendimiento = (floatval($total_venta)/floatval($total_visitas));
but when I do this, it tells me that there is an error, which is the following:
Fatal error: Uncaught DivisionByZeroError: Division by zero
the numbers i am using are $total_sales = 10 and $total_visits = 18 which gives me 0.555 but after that i am going to multiply it by 100, but the error is still there and it messes up some extra features of the page how can i use of those 0.555 without php detecting that they are 0?
The error:
indicates that an arithmetic exception is being caused since you are dividing by 0 , this occurs when the value of
$total_visitas
has the value of 0, in this case you can perform a validation:in this way when the value of
$total_visitas
is 0, the resulting value of$total_rendimiento
will be simply 0.