Easy Tutorial
❮ Php Looping For Func Filesystem Is Dir ❯

PHP mysqli_thread_id() Function

PHP MySQLi Reference Manual

Returns the thread ID of the current connection, then kills the connection:

<?php 
// Assume database username: root, password: 123456, database: tutorialpro 
$con = mysqli_connect("localhost", "root", "123456", "tutorialpro"); 
if (mysqli_connect_errno($con)) 
{ 
    echo "Failed to connect to MySQL: " . mysqli_connect_error(); 
} 
// Get thread id
$t_id = mysqli_thread_id($con);

// Kill thread
mysqli_kill($con, $t_id);
?>

Definition and Usage

The mysqli_thread_id() function returns the thread ID of the current connection, which can then be killed using the mysqli_kill() function.

Note: If the connection is lost and reconnected, the thread ID will change. Therefore, obtain the thread ID only when necessary.


Syntax

Parameter Description
connection Required. Specifies the MySQL connection to use.

Technical Details

Return Value: Returns the thread ID of the current connection.
PHP Version: 5+
--- ---
❮ Php Looping For Func Filesystem Is Dir ❯