title: PHP calculator division by zero error ?fix?
body: <p>I Want to make a calculator. I made the code but problem is when some number divide by zero it gives an Exception,so it is unable to generate the correct result, is there a fix for this? see code </p>
  
  <pre><code>&lt;?php
  $x = $_POST['x'];
  $y = $_POST['y'];
  $tafel = 10;
  $antwoord = '' ;
  {
      if($y = 0)
          return 'Voer voor y een ander getal in';
  }
  
  switch ($_POST['type']) {
      case 'plus':
          $antwoord = $x + $y;
          break;
      case 'keer':
          $antwoord = $x * $y;
          break;
      case 'wortel':
          $antwoord = sqrt($x);
          break;
      case 'min':
          $antwoord = $x - $y;
          break;
      case 'deel':
          $antwoord = $x / $y;
  
          break;
      case 'kwadraat':
          $antwoord = pow($x, 2);
          break;
      case 'macht':
          $antwoord = pow($x, $y);
          break;
      case 'tafel':
          for($i = $x; $i &lt;= 10; $i++){
          echo $x * $i.'&lt;br&gt;';
          }
          break;
      default:
          # code...
          break;
  }
  echo '&lt;h1 id="answer"&gt; Antwoord:&lt;/h1&gt;&lt;br&gt;';
  echo $antwoord;
              ?&gt;
  </code></pre>