This is really a basic question (hopefully). Most of the exception handling I did was with C #. In C #, any code that contains errors in a catch try block is handled by catch code. for instance
try
{
int divByZero=45/0;
}
catch(Exception ex)
{
errorCode.text=ex.message();
}
The error will be displayed in errorCode.text. If I tried to run the same code in php:
try{
$divByZero=45/0;
}
catch(Exception ex)
{
echo ex->getMessage();
}
The catch code does not run. Based on my limited understanding, php needs a throw. Doesn't that defeat the whole purpose of error checking? Doesn't that reduce the catch attempt to an if then statement? if (division by zero) throw error Please tell me that I do not need to anticipate every possible error in an attempt to catch a throw. If so, does it still make php error handling behave like C #?