Here's the solution
PHP Code:
$a = 10;
$b = 20;
$c = 4;
$d = 8;
$e = 1.0;
$f = $c + $d * 2;
$g = $f % 20;
$h = $b - $a + $c + 2;
$i = $h << $c;
$j = $i * $e;
echo $j;
Ok, so the best way to work this out is to work from the end back to the beginning. So first we look at out outcome variable $j and work back.
So, $j is equal to $i * $e, we know $e is 1.0, so we only need to worry about $i.
We can see that $i is equal to:
Since $h holds the result of a previous calculation, we must first discover its value before we can find the value of $i.
PHP Code:
$h = $b - $a + $c + 2
Now, we know $b is 20, $a is 10 and $c is 4 (as these variables were initialised with these values) so the previous statement becomes:
PHP Code:
$h = 20 - 10 + 4 + 2
which equals 16, so we now know that
Ok so we have our $h, we can now calculate $i:
or
Which means shift 16 4 bits to the left (Im not gunna bog you down with bit manipulation here, I'll release an article on this soon), so we can now determine that:
PHP Code:
16 << 1 = 32
32 << 1 = 64
64 << 1 = 128
128 << 1 = 256
so therefor:
Finally, now we know the value of $i, we can now determine the value of $j:
or
so, the answer to this little mystery is
256!