title: Average Calculation for PHP with variable issue
body: <p>Morning Everyone,</p>
  <p>I am trying to troubleshoot this code. I have made progress, but I am doing a simple average calculation. When I try and declare a variable before using it I have issues. When I try to just use it I get errors saying declare a variable.</p>
  <p>Any idea what I am doing incorrectly on the $Average portion. I either can't render the page or I get 0.00 because when I declare the variable I don't have an input for it yet.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
      // get the data from the form
      $first = filter_input(INPUT_POST, 'first');
      $last = filter_input(INPUT_POST, 'last');
      $one = filter_input(INPUT_POST, 'one',
          FILTER_VALIDATE_FLOAT);
      $two = filter_input(INPUT_POST, 'two',
          FILTER_VALIDATE_FLOAT);
      $three = filter_input(INPUT_POST, 'three',
          FILTER_VALIDATE_FLOAT);
      //var = $Average ;
      $Sum = filter_input(INPUT_POST, 'Sum');
  
      // validate Score one
      if ($one === FALSE ) {
          $error_message = 'Score one must be a valid number.'; 
      } else if ( $one &lt; 0 ) {
          $error_message = 'Score one cannot be less than zero.'; 
     // validate Score two
      if ($two === FALSE ) {
          $error_message = 'Score two must be a valid number.'; 
      } else if ( $two &lt; 0 ) {
          $error_message = 'Score two cannot be less than zero.'; 
      // validate Score three
      if ($three === FALSE ) {
          $error_message = 'Score three must be a valid number.'; 
      } else if ( $three &lt; 0 ) {
          $error_message = 'Score three cannot be less than zero.'; 
      // set error message to empty string if no invalid entries
      } else {
          $error_message = ''; }
  
      // if an error message exists, go to the index page
      if ($error_message != '') {
          include('index.php');
          exit();
      }
      
      // calculate the average score
          //$Sum = $one; + $two; + $three;
          //$Average = $Sum / 3;}}
          $Average = ($one + $two + $three)/3;}}
          $Average = number_format($Average, 2);
      
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Assignment 2&lt;/title&gt;
      &lt;link rel="stylesheet" type="text/css" href="main.css"/&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;main&gt;
          &lt;h1&gt;Assignment 2&lt;/h1&gt;
  
          &lt;label&gt;Student Name:&lt;/label&gt;
          &lt;span&gt;&lt;?php echo $first; ?&gt;&lt;/span&gt;&lt;span&gt;&lt;?php echo " ",  $last; ?&gt;&lt;/span&gt;&lt;br /&gt;
  
          &lt;label&gt;Your Scores:&lt;/label&gt;
          &lt;span&gt;&lt;?php echo $one, ","; ?&gt;&lt;/span&gt; &lt;span&gt;&lt;?php echo $two, ","; ?&gt;&lt;/span&gt; &lt;span&gt;&lt;?php echo $three; ?&gt;&lt;/span&gt;&lt;br /&gt;
  
          &lt;label&gt;Average:&lt;/label&gt;
          &lt;span&gt;&lt;?php echo $Average; ?&gt;&lt;/span&gt;&lt;br /&gt;
          
      &lt;/main&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>