title: Is it necessary to close prepared statement in php
body: <p>Is it necessary to close the prepared statement in php by using <code>$stmt-&gt;close();</code></p>
  <pre><code> &lt;?php
  $servername = &quot;localhost&quot;;
  $username = &quot;username&quot;;
  $password = &quot;password&quot;;
  $dbname = &quot;myDB&quot;;
  
  // Create connection
  $conn = new mysqli($servername, $username, $password, $dbname);
  
  // Check connection
  if ($conn-&gt;connect_error) {
    die(&quot;Connection failed: &quot; . $conn-&gt;connect_error);
  }
  
  // prepare and bind
  $stmt = $conn-&gt;prepare(&quot;INSERT INTO MyGuests (firstname, lastname, email) VALUES (?, ?, ?)&quot;);
  $stmt-&gt;bind_param(&quot;sss&quot;, $firstname, $lastname, $email);
  
  // set parameters and execute
  $firstname = &quot;John&quot;;
  $lastname = &quot;Doe&quot;;
  $email = &quot;john@example.com&quot;;
  $stmt-&gt;execute();
  
  $firstname = &quot;Mary&quot;;
  $lastname = &quot;Moe&quot;;
  $email = &quot;mary@example.com&quot;;
  $stmt-&gt;execute();
  
  echo &quot;New records created successfully&quot;;
  
  $stmt-&gt;close();
  $conn-&gt;close();
  ?&gt; 
  </code></pre>