Beginner PHP calculator
No it's not possible writing 

Variable3 = Var1 Variable Var2


With the Variable as an operator, i decided to use call_user_func to call the BC Math functions http://php.net/manual/en/ref.bc.php

I removed the $mathinput since you were not using it anyway.


  Result


&lt;?php
$input1    = $_GET["num1"];
$input2    = $_GET["num2"];
$operator  = $_GET["symbol"];

$operators = [
    '+' =&gt; 'bcadd',
    '-' =&gt; 'bcsub',
    '*' =&gt; 'bcmul',
    '/' =&gt; 'bcdiv',
    '%' =&gt; 'bcmod',
];

$result = array_key_exists($operator, $operators) 
        &amp;&amp; is_numeric($input1) 
        &amp;&amp; is_numeric($input2) 
        ? call_user_func($operators[$operator], $input1, $input2) 
        : null;
?&gt;      

&lt;?php if (!$result) : ?&gt;
        &lt;div id="result"&gt;
            &lt;p&gt;Error: Invalid input or arithmetic operator.&lt;/p&gt; 
        &lt;/div&gt;
&lt;?php else: ?&gt;
        &lt;div id="result"&gt;
            &lt;p&gt;Result: &lt;?= $result; ?&gt;&lt;/p&gt; 
        &lt;/div&gt;
&lt;?php endif; ?&gt;



  EDIT


The array_key_exists function checks if a given key exists in the array.
http://php.net/manual/en/function.array-key-exists.php

The following is a shorthand if / ternary logic

$var = array_key_exists($operator, $operators) 
&amp;&amp; is_numeric($input1) 
&amp;&amp; is_numeric($input2)
? 'all true' : 'conditions not met';


Simply checks if all the conditions are true, if so the above example would set $var to a string with a value of 'all true', if one of the conditions would return false, the $var would be set to 'conditions not met'

You could write the above snippet using regular if / else statements like this:

if(array_key_exists($operator, $operators) &amp;&amp; is_numeric($input1) &amp;&amp; is_numeric($input2)) {
    $var = 'all true';
}
else {
    $var = 'conditions not met';
}


Using ternary logic could have some of the following advantages when used properly.


Makes coding simple if/else logic quicker
Makes code shorter 
Makes maintaining code quicker, easier