title: In php: how to pass the $conn (mysqli) object between functions in the same class?
body: <p>I do have the following piece of php code I'm writting:</p>
  
  <pre><code>public $conn;
  
  public function start(){
      $this-&gt;conn = new mysqli($this-&gt;servername, $this-&gt;username, $this-&gt;password, $this-&gt;dbName);
      if ($this-&gt;conn-&gt;connect_error) {
          die("Connection failed: " . $this-&gt;conn-&gt;connect_error);
      }
  
  
  }
  
  public function sql($q){
  
      $res=  $this-&gt;conn-&gt;query($q);  
      echo $res;
      return $res;    
  }
  </code></pre>
  
  <p>The following code gives error when used as I create an object of the db class.</p>
  
  <p>How can I do to pass the $conn object between the function start and the function sql properly?</p>
  
  <p>Thanks</p>