Hello Scott,

Thanks. I'll read up on it now...and post my thoughts.

Before I read I'll ask this question. What's the difference between
this example below and what you just explained?

[EMAIL PROTECTED]:~/webdev$ php test.php
Gotcha!
[EMAIL PROTECTED]:~/webdev$ cat test.php
<?php

function a($val)
{
       if ( $val < 0 ) return FALSE;
       if ( $val >= 0 ) return TRUE;
}

if ( a(-1) )
{
       printf("Not here\n");
}
else
{
       printf("Gotcha!\n");
}


- Ben
----- Original Message ----- From: "Scott Mattocks" <[EMAIL PROTECTED]>
To: "NYPHP Talk" <[email protected]>
Sent: Wednesday, November 28, 2007 11:11 AM
Subject: Re: [nyphp-talk] If/else vs Try/catch


Ben Sgro (ProjectSkyLine) wrote:
I see ample use of try/catch. Why? Why is it better/different than if/else?

You are talking about two completely different things here. If/else is for testing a condition. Try/catch is for handling exceptions. If an exception is thrown within a try/catch block the code in the catch section will be executed. The two are not interchangeable. You should read up on exception handling if you think you may need to use try/catch.

http://us2.php.net/manual/en/language.exceptions.php

--
Scott Mattocks
Author: Pro PHP-GTK
http://www.crisscott.com
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to