If you use your own DBException handling for example
<?php
if (!@real_connect(HOST, USERNAME, PASSWORD, NAME, PORT))
{
throw new DBException(connect_errno);
}
?>
Then turn off errors like this for php 8 >
<?php
mysqli_report(MYSQLI_REPORT_OFF);
?>