MySQLi - Close



Syntax

bool mysqli::close ( void )

Definition and Usage

It closes a previously opened database connection

Example

Try out following example −

<?php
   $servername = "localhost:3306";
   $username = "root";
   $password = "";   
   $dbname = "TUTORIALS";
   $conn = new mysqli($servername, $username, $password, $dbname);

   if ($conn->connect_error) {
      die("Connection failed: " . $conn->connect_error);
   } 
   echo "Database connected";

   mysqli_close($conn);
?>

The sample output of the above code should be like this −

Database connected
mysqli_useful_functions.htm
Advertisements