Home  >  Article  >  Backend Development  >  How to close mysql connection in php

How to close mysql connection in php

青灯夜游
青灯夜游Original
2021-03-17 17:48:552755browse

The mysqli_close() function can be used in php to close the mysql connection, the syntax format is "mysqli_close(connection);". The mysqli_close() function can close a previously opened database connection and returns TRUE if successful, otherwise it returns FALSE.

How to close mysql connection in php

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

php close mysql connection

When the database operation is completed, you can use mysql_close to close the database connection.

mysqli_close() function closes the previously opened database connection. The syntax is as follows:

mysqli_close(connection);
  • Parameter connection: required. Specifies the MySQL connection to be closed.​

Return value: TRUE if successful, FALSE if failed.​

When there are multiple database connections, you can set the connection resource parameters to close the specified database connection.

$link = mysql_connect($host, $user, $pass);
mysql_close($link);

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to close mysql 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