PHP | mysqli_debug() Function

PHP mysqli_debug() Function


Hello folks! welcome back to a new edition of our tutorial on PHP. In this tutorial guide, we are going to be studying about the PHP mysqli_debug() Function.

The PHP mysqli_debug() function accepts a string value which represents 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 PHP functions returns a boolean true.

PHP Version

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

Example1

Following example demonstrates the usage of the built-in 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 going to be rounding up for this tutorial post. In our next tutorial, we are going to be discussing about the PHP mysqli_dump_debug_info() Function.

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.