I\'m following an OOP mysqli course. When connecting to the database, they use the following script:
$db = new mysqli(\"host\", \"user\", \"password\", \"dat
Are you asking about what's the different with $db->connect_error
and try/catch
?
$db->connect_error
mostly for the errors which we already knew (username incorrect, etc.)
and try/catch
is about system level, once an error occur,
PHP will search for the nearest try/catch block,
once it catch something, PHP will still continue like nothing happened before,
but if you don't have any try/catch
block and set_exception_handler()
too,
PHP will just stop by the error.