mercredi 25 novembre 2020

Set function value based on variable

I need to assign the variable Freight_class to the value: Bigheavy, Largebox or Littlebox. For that I have to use the value of Freight. If the value of Freight is greater than 225, Freight_class must be set to Bigheavy. If Freight is greater than 99, Freight_class must be equal to Largebox. Under 99, Freight_class must be Littlebox.

Say Freight=40, then Freight_class should be Littlebox. But I can not get it to work. What do I do wrong

<?php
$Freight=40;

function Freight_class($Freight) {
if ($Freight > '225') {
    return ('Bigheavy');
} elseif ($Freight > '99') {
    return ('Largebox');
} else {
    return ('Littlebox');
}
}

echo $Freight_class;

Aucun commentaire:

Enregistrer un commentaire