You are here: Re: My try-catch doesn' t "catch". What's wrong? « PHP Programming Language « IT news, forums, messages
Re: My try-catch doesn' t "catch". What's wrong?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация