Posted by lwoods on 10/06/14 11:23
Thanks....
Larry
"Janwillem Borleffs" <jw@jwscripts.com> wrote in message
news:42f67a95$0$4831$dbd4b001@news.euronet.nl...
> lwoods wrote:
> > Why isn't my "catch" catching?
> >
>
> With try-catch only exceptions which are actually thrown will be handled,
> not warnings:
>
> class Math {
> function divide($a, $b) {
> if ($b == 0) {
> throw new Exception('division by zero');
> } else {
> return $a / $b;
> }
> }
> }
>
> try {
> $math = new Math;
> print $math->divide(2, 0);
> }catch (Exception $e) {
> print "Exception caught:<br>";
> print "Code: ".$e->getCode()."<br>";
> print "Message: ".$e->getMessage()."<br>";
> print "Error thrown on Line: ".$e->getLine()."<br>";
> }
>
>
> JW
>
>
>
Navigation:
[Reply to this message]
|