Description
The following code:
<?php
$mysqli = new mysqli();
$value = $mysqli->options(-1, 'invalid_option');
var_dump($value);
Resulted in this output:
But I expected this output instead:
Per the mysqli::options documentation,
If mysqli error reporting is enabled (MYSQLI_REPORT_ERROR) and the requested operation fails, a warning is generated. If, in addition, the mode is set to MYSQLI_REPORT_STRICT, a mysqli_sql_exception is thrown instead.
Per the mysqli_driver::$report_mode documentation, this should be the default behavior:
PHP 8.1. The default value is now MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT. Previously, it was MYSQLI_REPORT_OFF.
For reference, mysqli::set_charset behaves as expected:
<?php
$mysqli = new mysqli('127.0.0.1', 'root', 'Passw0rd!');
try {
$mysqli->set_charset('garbage');
} catch (mysqli_sql_exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
// Caught exception: Invalid character set was provided
PHP Version
PHP 8.5.2 (cli) (built: Jan 13 2026 21:40:53) (NTS)
Copyright (c) The PHP Group
Built by Shivam Mathur
Zend Engine v4.5.2, Copyright (c) Zend Technologies
with Xdebug v3.5.0, Copyright (c) 2002-2025, by Derick Rethans
with Zend OPcache v8.5.2, Copyright (c), by Zend Technologies
Operating System
macOS
Description
The following code:
Resulted in this output:
But I expected this output instead:
Per the
mysqli::optionsdocumentation,Per the
mysqli_driver::$report_modedocumentation, this should be the default behavior:For reference,
mysqli::set_charsetbehaves as expected:PHP Version
Operating System
macOS