PHP: exceptions vs errors? -
maybe i'm missing somewhere in php manual, difference between error , exception? difference can see errors , exceptions handled differently. causes exception , causes error?
exceptions thrown - intended caught. errors unrecoverable. lets instance - have block of code insert row database. possible call fails (duplicate id) - want have "error" in case "exception". when inserting these rows, can this
try { $row->insert(); $inserted = true; } catch (exception $e) { echo "there error inserting row - ".$e->getmessage(); $inserted = false; } echo "some more stuff";
program execution continue - because 'caught' exception. exception treated error unless caught. allow continue program execution after fails well.
Comments
Post a Comment