For some reason when ever I compile this code, it gives me zero. Why is this?
$aou = 5; //Amount of upvotes
$aod = 2; //Amount of downvotes
$elo = (auo/aod) * 150; //Elo
echo "Your elo is: " . $elo;
For some reason when ever I compile this code, it gives me zero. Why is this?
$aou = 5; //Amount of upvotes
$aod = 2; //Amount of downvotes
$elo = (auo/aod) * 150; //Elo
echo "Your elo is: " . $elo;
The problem is that you type auo
and aod
instead of $auo
and $aod
. PHP is trying to look up constants of those names, and not variables.
Constants are defined and used without the dollar sign, e.g.
const FOO = 123;
echo FOO;
But variables need $
every time you use them, thus
$bar = 123;
echo $bar;