PHP | mysqli_debug() Function

PHP mysqli_debug() Function


Hello dear readers! welcome back to another edition of our tutorial on PHP. In this tutorial guide, we are going to be discussing about the PHP mysqli_debug() Function.

The built-in PHP mysqli_debug() function accepts a string value representing the required debugging operation to be performed as a parameter and, performs it using the Fred Fish debugging library.

Syntax

Following below is the syntax to use this function -

mysqli_debug($message);


Parameter Details

Sr.NoParameter & Description
1

message(Mandatory)

This is a string value representing the required debugging operation to be performed.


Return Value

This built-in PHP functions returns a boolean true.

PHP Version

This built-in function was introduced in PHP version 5 and works in all the later versions.

Example1

Following example demonstrates the usage of the PHP mysqli_debug() function (in procedural style) -

<?php
   $debug = mysqli_debug("T:n:t:m:x:F:L:o,/sample.txt");
   print($debug);
?>

Output

When the above code is executed, it will produce the following result -

1

Example2

Try the following example below -

<?php
   $servername = "localhost";
   $username = "root";
   $password = "password";
   $dbname = "mydb";
   $conn = new mysqli("localhost", "root", "password", "mydb");

   if ($conn->connect_error) {
      die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
   } 
   echo 'Success... ' . mysqli_get_host_info($conn) . "\n";
   mysqli_debug("d:t:o,debug.txt");
   mysqli_autocommit($conn,FALSE);
   mysqli_query($conn,"INSERT INTO tutorials_auto (id,name) VALUES (10,'sai')");
   mysqli_commit($conn);
   
   mysqli_close($conn);
?>

Output

When the above code is executed, it will produce the following result -

Success... localhost via TCP/IP


Alright guys! This is where we are rounding up for this tutorial post. In our next tutorial, we will discuss about the mysqli_dump_debug_info() Function in PHP.

Do feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Do follow us on our various social media handles available and also subscribe to our newsletter to get our tutorial posts delivered directly to your emails.

Thanks for reading and bye for now.