0
I usually see that everyone uses PHP with Pdoexception or the more generic Exception $e
, but PHP has exceptions more specific? as in JAVA Nullpointerexception or Arithmeticexception or Numberformatexception
And do I use them the same way as Exception $e? Only replacing Exception with the more specific
And the second part of the question @Wallace Maxters?
– sadBill
Yes, the syntax does not change from one exception to the other. Related: How and when to use exceptions in PHP?
– Woss
Thanks for the help
– sadBill
Each Exception has its own methods that are suitable for the task. For example the
PDOException
has a property that returns theSQLSTATE
which is useful to know what kind of error happened to the query or database, which is not suitable for handling a file.– rray
If you need something more specific, just create your own exceptions...
– Wallace Maxters