I have done a lot of PHP coding but never used try/catch
before. First time user. It won't work, does not even compile. I am trying this very simple example.
$x = 0;
try {
if ($x == 0) {
throw new Exception('x is zero');
}
} catch (Exception $ex) {
echo 'Caught exception: ', $ex->getMessage();
}
echo 'after try block';
When I run this, I get this error message referring to the line with the catch in it.
Parse error: syntax error, unexpected '$ex' (T_VARIABLE), expecting ',' or ')'
Was expecting to get the Caught exception line displayed.