title: Simple php calculator with form validation
body: <p>Today i wrote a simple calculator but i have a problem with form validation. I do perform validation as i want calculator to calculate numbers, not objects or arrays, etc. When i perform validation input can't be validated as a number because php gives me warning about strings being passed, not a numbers, no matter what i input.</p>
  
  <p>This is my code:</p>
  
  <pre><code>&lt;?php
  $A = trim(strip_tags(filter_input(INPUT_GET, 'A', 'FILTER_VALIDATE_FLOAT')));
  $B = trim(strip_tags(filter_input(INPUT_GET, 'B', 'FILTER_VALIDATE_FLOAT')));
  $operation = trim(strip_tags(filter_input(INPUT_GET, 'operation', 'FILTER_VALIDATE_STRING')));
      if(isset($A) &amp;&amp; isset($B) &amp;&amp; isset($operation)){
        if(!is_numeric($A) || !is_numeric($B)){
          echo "Invalid parameters.";
        }
        else{
          if($operation == 'plus'){
            echo "$A + $B = ", $A + $B;
          }
          else if($operation == 'minus'){
            echo "$A - $B = ", $A - $B;
          }
          else if($operation == 'multiplication'){
            echo "$A * $B = ", $A * $B;
          }
          else if($operation == 'division'){
            echo "$A / $B = ", $A / $B;
          }
          else{
            echo "Invalid operator.";
          }
        }
      } else {
        echo "No operators.";
      }
      ?&gt; 
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;form name='form1' action="&lt;?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?&gt;" method='get'&gt;
        &lt;div&gt;
          &lt;p&gt;argument 1 &lt;input type='text' name='A'&gt;&lt;/p&gt;
          + &lt;input type='radio' name='operation' value='plus' checked='checked'&gt;
          - &lt;input type='radio' name='operation' value='minus'&gt;
          * &lt;input type='radio' name='operation' value='multiplication'&gt;
          / &lt;input type='radio' name='operation' value='division'&gt;
          &lt;p&gt;argument 2 &lt;input type='text' name='B'&gt;&lt;/p&gt;
          &lt;input type='submit' value="Calculate"&gt;
        &lt;/div&gt;
      &lt;/form&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>These are warning messages which i get when i open file in browser:
  Warning: filter_input() expects parameter 3 to be integer, string given in ./file.php on line 3</p>
  
  <p>Warning: filter_input() expects parameter 3 to be integer, string given in ./file.php on line 4</p>
  
  <p>Warning: filter_input() expects parameter 3 to be integer, string given in ./file.php on line 5
  Invalid parameters.</p>
  
  <p>Also i got interesting thing about filter input. When i write: FILTER_VALIDATE_STRING without " ' " then i'm getting additional warning:
  Warning: Use of undefined constant FILTER_VALIDATE_STRING - assumed 'FILTER_VALIDATE_STRING' (this will throw an Error in a future version of PHP) in ./file.php on line 4
  Same goes to filter_validate_float.</p>
  
  <p>What am i doing wrong and what should i improve in this form validation?</p>