In PHP, mysqli_debug() turns on low-level MySQLi client debugging using a control string of flags.
Object-oriented style uses $mysqli->debug($options), though many examples call the procedural form before connecting. A common pattern writes a trace file with options like "d:t:o,/tmp/client.trace". This is for diagnosing the client library, not everyday application logging.
Syntax
Call mysqli_debug() with the values you need. Start with this line.
PHP
mysqli_debug("d:t:o,/tmp/client.trace");
Call
What it does
mysqli_debug("d:t:o,/tmp/client.trace")
Starts a debug trace written to a file.
mysqli_debug("d:t:O,/tmp/client.trace")
Similar trace with flush behavior depending on build flags.
$mysqli->debug("d:t:o,/tmp/client.trace")
Object-oriented method form.
Debugging support must be available in the MySQL native driver / client build. On many shared hosts mysqli_debug() will not produce a useful file. Prefer application logging and mysqli_error() for normal troubleshooting.
Library declarations
PHP
mysqli_debug(string $options): true
Parameters
Parameter
Description
options
Required. A colon-separated debug control string (flags and optional output path).
Return Value
Return Value
Description
true
Always true in PHP 8+.
PHP Examples
Example 1 — Enable a Client Trace File
Call mysqli_debug with a typical options string before connecting.