NYCPHP Meetup

NYPHP.org

[nycphp-talk] If/else vs Try/catch

Scott Mattocks scott at crisscott.com
Wed Nov 28 11:11:33 EST 2007


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



More information about the talk mailing list