How to enable mysqli error reporting via INI settings?

Viewed 256

This will be a rather short question but I have not been able to locate a way to set the following within my .htaccess file

Im looking for the .htaccess equivalent of:

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

1 Answers

There is no PHP ini setting for enabling mysqli error reporting. The only way to do it, is via the command you have in the question. This should never be a huge problem, since it is only a single line of code, which must always be put before new mysqli. In total the connection code in your whole application should be no more than 3 lines of code in a single place. All that you need is this:

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new mysqli(); // values coming from INI file
$mysqli->set_charset('utf8mb4'); // always set the charset
Related