How to close database connection in php

王林
Release: 2023-03-03 16:16:02
Original
4439 people have browsed it

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);
Copy after login

(Recommended video tutorial: php video tutorial)

Code implementation:

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

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

mysqli_close($con);
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template