Home >Backend Development >PHP Problem >How to close database connection in php

How to close database connection in php

王林
王林Original
2020-07-31 15:47:264446browse

How to close the database connection in php: You can use the mysqli_close() function to close the previously opened database connection. The specific usage method is: [mysqli_close($conn)], if successful, it returns TRUE, otherwise it returns FALSE.

How to close database connection in php

The mysqli_close() function closes the previously opened database connection, returning TRUE if successful and FALSE if failed.

(Recommended tutorial: php graphic tutorial)

Function syntax:

mysqli_close(connection);

(Recommended video tutorial: php video tutorial)

Code implementation:

<?php
$con=mysqli_connect("localhost","my_user","my_password","my_db");

// ....一些 PHP 代码...

mysqli_close($con);
?>

The above is the detailed content of How to close database connection in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn