How do you close a connection to a MySQL database in PHP?
- Using the mysqli_close() function
- Using the mysql_close() function
- Using the pdo_close() function
- Using the database_close() function
To close a connection to a MySQL database in PHP, you can use the mysqli_close() function. This function takes the MySQLi object representing the database connection as a parameter and closes the connection. It is important to explicitly close the database connection when you're done with it to free up resources. However, PHP automatically closes the connection at the end of the script execution, so it is not always necessary to explicitly close the connection, but it's good practice to do so.
Loading...
Related Quiz
- Which of the following are true about the $_GET superglobal in PHP?
- PHP scripts are enclosed within ______ tags.
- You are writing a PHP script and you need to check if a string matches a specific pattern. How would you do this using Regular Expressions in PHP?
- PHP code is enclosed in ______ and ______ tags.
- What are the differences between a static method and a regular method in PHP?