Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add / Divide Numbers in PHP

I am working on a Facebook App that needs to be able to average three numbers. But, it always return 0 as the answer. Here is my code:

$y = 100;
$n = 250;
$m = 300;
$number = ($y + $n + $m / 3);
echo 'Index: '.$number;

It always displays Index: 0

Any ideas?

like image 795
Zac Brown Avatar asked Dec 06 '22 01:12

Zac Brown


1 Answers

$y = 100;
$n = 250;
$m = 300;
$number = ($y + $n + $m) / 3;
echo 'Index: '.$number;

Also - you missed ; in the end of the first 3 lines

like image 158
zerkms Avatar answered Jan 08 '23 09:01

zerkms