first time asking on the site so sorry if the question isnt too detailed.
My code:
<?php
$a = ($_POST['a']);
$b = ($_POST['b']);
$op = ($_POST['c']);
$ans = $a $op $b;
echo $ans;
?>
As you can see I'm passing in numbers $a
and $b
and want to do something with them depending on the $op
which gets passed through.
My problem is that I cant get at the variable $op
in the way I want to. Ideally if $op
is "+"
id like the $ans
to be something like 1 + 2
.
I'm guessing that I have a problem with syntax.
Many thanks
David