Return the thread ID of the current connection, then kill the connection:
<?php // Assume database username: root, password: 123456, database: CODERCTO $con=mysqli_connect("localhost","root","123456","CODERCTO"); if (mysqli_connect_errno($con)) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // Get the thread id$t_id=mysqli_thread_id($con);//Kill the thread mysqli_kill($con,$t_id);?>
The mysqli_thread_id() function returns the thread ID of the current connection, and then the mysqli_kill() function is used to kill the connection.
Note: If the connection is damaged and reconnected, the thread ID will change. So only get the thread ID if you need it.
mysqli_thread_id( connection ) ;
parameter | describe |
---|---|
connection | Required. Specifies the MySQL connection to use. |
Return value: | Returns the thread ID of the current connection. |
---|---|
PHP version: | 5+ |