I have the hours worked by a worker and the daily salary. Such that:
$horas = 8;
$precio = 88;
$pagar = 0;
if($horas > 0){
$pagar = $precio
}
return $pagar.
Work what you work, unless $horas
is 0, I'll pay for the day. Then I would like to save the if (in the real code it is all more complex although in the example it seems simple). I have this:
$pagar = $precio * ($horas/$horas);
Of course this is that if $horas
is 8 and divided among itself is 1, and I can multiply it well. The fact is that if $horas
is 0, splitting between is not quite correct.
And here the question of the title, can I multiply directly by the Boolean result of the number? that is, something like:
$precio * intval(boolval($horas));
this case works, but not in PHP 5.4
, since boolval
is for PHP 5.5+
and I also think it should be simpler than calling 2 functions
Thanks