mysqli::stmt_init() And mysqli_get_charset() Are Deprecated
mysqli::stmt_init() creates a statement object to prepare later, and mysqli_get_charset() returns information about the connection’s current character set. In PHP 8.6, calling either emits a deprecation notice, recommending mysqli::prepare() and mysqli_character_set_name() respectively; both functions keep their previous behavior otherwise.
PHP code
<?php
$mysqli = new mysqli();
try {
$mysqli->stmt_init();
} catch (\Error $e) {
echo "Error: ".$e->getMessage()."\n";
}
try {
var_dump(mysqli_get_charset($mysqli));
} catch (\Error $e) {
echo "Error: ".$e->getMessage()."\n";
}
?>
Before
Error: mysqli object is not fully initialized
Error: mysqli object is not fully initialized
After
PHP Deprecated: Method mysqli::stmt_init() is deprecated since 8.6, use mysqli::prepare() instead in /codes/mysqliStmtInitGetCharsetDeprecated86.php on line 6
Deprecated: Method mysqli::stmt_init() is deprecated since 8.6, use mysqli::prepare() instead in /codes/mysqliStmtInitGetCharsetDeprecated86.php on line 6
Error: mysqli object is not fully initialized
PHP Deprecated: Function mysqli_get_charset() is deprecated since 8.6, did you mean mysqli_character_set_name()? in /codes/mysqliStmtInitGetCharsetDeprecated86.php on line 12
Deprecated: Function mysqli_get_charset() is deprecated since 8.6, did you mean mysqli_character_set_name()? in /codes/mysqliStmtInitGetCharsetDeprecated86.php on line 12
Error: mysqli object is not fully initialized
PHP version change
This behavior was deprecated in 8.6.
This behavior changed in .
See Also
Error Messages
- Method mysqli::stmt_init() is deprecated since 8.6, use mysqli::prepare() instead
- Function mysqli_get_charset() is deprecated since 8.6, did you mean mysqli_character_set_name()?