if you need to close database connection then php provide mysql_close() function that accept connection as parameter and return boolean value.
PHP MySQL Database Connection Close Example:
After creating database connection in php application, if you need to close database connection then php provide mysql_close() function that accept connection as parameter and return boolean value(true for success or false for failure).
Syntax:
mysql_close(connection)
Example:
<?php $connection = mysql_connect("localhost","root","root"); if (!$connection) { die('PHP Mysql database connection could not connect : ' . mysql_error()); } else{ echo "PHP MySql database connection created.<br />"; } mysql_close($connection); echo "PHP MySql database connection closed.<br />"; ?>
After running this example the output is:
Output:
PHP MySql database connection created. PHP MySql database connection closed.
[ 0 ] Comments