title: set_error_handler, How do I suppress E_NOTICE in php
body: <p>How do I suppress E_NOTICE in this php function, I don't want to get email, about non declaret variables, from a production site ? </p>
  
  <p>I have tried to out comment case E_NOTICE: but then the program just jumps down to default: exit("Unknown error at $errfile:$errline"); near the end of the script.</p>
  
  <p>I want the opportunity to commented out the error feedback I don't want ??</p>
  
  <pre><code>&lt;?php
  
  function errorHandler($errno, $errstr, $errfile, $errline) {
  
      function errorMail($errno, $errstr, $errfile, $errline) {
  
          $recvmail = "yourmail";
  
      $fejlkode = array(
          1 =&gt; "E_ERROR",
          2 =&gt; "E_WARNING",
          4 =&gt; "E_PARSE",
          8 =&gt; "E_NOTICE",
          16 =&gt; "E_CORE_ERROR",
          32 =&gt; "E_CORE_WARNING",
          64 =&gt; "E_COMPILE_ERROR",
          128 =&gt; "E_COMPILE_WARNING",
          256 =&gt; "E_USER_ERROR",
          512 =&gt; "E_USER_WARNING",
          1024 =&gt; "E_USER_NOTICE",
          2048 =&gt; "E_STRICT",
          4096 =&gt; "E_RECOVERABLE_ERROR",
          8192 =&gt; "E_DEPRECATED",
          16384 =&gt; "E_USER_DEPRECATED",
  
      );
  
      $mail = new PHPMailer;
          $mail-&gt;From = 'mailSender';
          $mail-&gt;FromName = 'your firm name';
          $mail-&gt;AddAddress($recvmail, "your name");  // Add a recipient
          $mail-&gt;SetLanguage('dk', './');
          $mail-&gt;Subject = utf8_decode("Fejl type:" . $errno .' -&gt; '. $fejlkode[$errno]);
          $mail-&gt;Body    = utf8_decode($errstr.' &lt;br&gt;'.$errfile.': '.$errline);
          $mail-&gt;AltBody = $errstr.$errfile.$errline.$errno;
  
          if(!$mail-&gt;Send()) {
            echo 'Message could not be sent.';
            echo 'Mailer Error: ' . $mail-&gt;ErrorInfo;
            exit;
         }  
  }
  
  switch ($errno) {
      case E_NOTICE:
      case E_USER_NOTICE:
      case E_DEPRECATED:
      case E_USER_DEPRECATED:
      case E_STRICT:
  
          errorMail($errno, $errstr, $errfile, $errline);
  
          break;
  
      case E_WARNING:
      case E_USER_WARNING:
         errorMail($errno, $errstr, $errfile, $errline);
          break;
  
      case E_ERROR:
      case E_USER_ERROR:
         errorMail($errno, $errstr, $errfile, $errline);
          exit("FATAL error $errstr at $errfile:$errline");
  
      default:
  
          exit("Unknown error at $errfile:$errline");
      }
  }
  
  set_error_handler("errorHandler");
  ?&gt;
  </code></pre>