In regards to Error handling in PHP -- As far I know there are 3 styles:
die()
orexit()
style:$con = mysql_connect("localhost","root","password"); if (!$con) { die('Could not connect: ' . mysql_error()); }
throw Exception
style:if (!function_exists('curl_init')) { throw new Exception('need the CURL PHP extension. Recomplie PHP with curl'); }
trigger_error()
style:if(!is_array($config) && isset($config)) { trigger_error('Error: config is not an array or is not set', E_USER_ERROR); }
Now, in the PHP manual all three methods are used.
What I want to know is which style should I prefer & why?
Are these 3 drop in replacements of each other & therefore can be used interchangeably?
Slightly OT: Is it just me or everyone thinks PHP error handling options are just too many to the extent it confuses php developers?