title: Suppressing PHP Errors & Warnings Using @ Not working with set_error_handler
body: <p>I'm trying to connect to TCP Server, When the server is working i should get true and when it is, I supposed to get false.</p>
  
  <p>But that what I'm getting instead of false:</p>
  
  <pre><code>    Error: [2], fsockopen(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in /website/classes/Main.php on line 2874 
  </code></pre>
  
  <p>My code: </p>
  
  <pre><code>public function checkInternetConnection(){
  
          $connected = @fsockopen("www.gossssogle.com", 80);
  
          if (!$connected){
            return false;
          }else{
              fclose($connected);
              return true;
          }
          return $is_conn;
  
  }
  </code></pre>
  
  <p>The problem I guess that I'm using set_error_handler so @ before function name isn't working</p>
  
  <pre><code>set_error_handler('customError');
  </code></pre>
  
  <p>Error Handler function</p>
  
  <pre><code>    function  customError($errno, $errstr, $errfile, $errline, $errcontext){
      $error_number = rand(1111 , 99999999);
      $message = "Error Number:" . $error_number . "\r\n";
      $message .= date("Y-m-d H:i:s")."\r\n";
      $message .= "Error: [" . $errno ."], " . "$errstr in $errfile on line $errline \r\n, ";
      $message .= "Variables:" . print_r($errcontext, true) . "\r\n";
  
  
  
      error_log($message, 3, log_file);
  
     throw new internalError();
  }
  </code></pre>
  
  <p><strong>Q:</strong>
  How can I check if the connection status instead of getting PHP error? </p>