title: Warning: mysqli_close() expects parameter 1 to be mysqli, null given in 1
body: <p>first sorry for my english:) you tell my why i have this warning when i call magic method __destructor(), i don't think that is scope of property connex, help my...thank you to all! </p>
  
  <pre><code>&lt;?php
  
  class Connect{
  
   protected $user;
   protected $pass;
   protected $host;
   protected $db;
   protected $query;
   protected $result;
   private $connex;
  
  
   function __construct($host,$user,$pass,$database){
  
    $this-&gt;host=$host;
    $this-&gt;user=$user;
    $this-&gt;pass=$pass;
    $this-&gt;db=$database;
  
  
  
    // connesione al database
  
    $this-&gt;connex = new mysqli("$this-&gt;host", "$this-&gt;user", "$this-&gt;pass", "$this-&gt;db");
    if ($this-&gt;connex-&gt;connect_errno) {
     echo "Failed to connect to MySQL: (" . $this-&gt;connect_errno . ") " . $this-&gt;connect_error;
    }
    // echo 'connessione stabilita' . "\n";
  
   }  
  
  
  function __destruct(){
   mysqli_close($this-&gt;connex);
   $this-&gt;connex = null; 
  }
  
  
  }
  
  
  
  $ist = new Connect("localhost","root","","mio");
  $ist-&gt;__destruct();
  </code></pre>