jeudi 20 août 2020

IF Conditional in a Formula in PHP [duplicate]

how can I do this little function in PHP, my specific doubt is in the part that I use the IF conditionals in the code that I share, this can't be run, I don't know if I can do something like that in PHP, how can I do this correctly. I really will appreciate your help!

function updateAvg_noi($bean, $event, $arguments)
         {
            $bean->avg_noi_c = ($bean->year_1_noi_c + $bean->year_2_noi_c + $bean->year_3_noi_c) / 
            (
                (if($bean->year_1_c == NULL){0;}else{1;}) + 
                (if($bean->year_2_c == NULL){0;}else{1;}) + 
                (if($bean->year_3_c == NULL){0;}else{1;})
            );
         }

Aucun commentaire:

Enregistrer un commentaire