News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHP-Coding-Practices.com:
Try-Catch Syntax Weirdness
June 22, 2007 @ 13:28:00

In working with his code recently, Tim Koschuetzki noticed something odd with a block of try/catch code:

I just noticed today, that PHP's try catch blocks require curly braces. Anybody has an idea why it is like that? I have used curly braces by default up until now, so I just stumbled upon this weirdness today.

He includes two examples, one with a curly brace after the catch clause and the other without. This is different than several other control structures (like ifs) that don't require the curly brace when there's only the one line following it.

1 comment voice your opinion now!
try catch curlybrace require try catch curlybrace require


blog comments powered by Disqus

Similar Posts

Vance Lucas: Handling Exceptions in Gearman Tasks (Even Background Ones)

Chris Hartjes' Blog: The Story and Rebirth Of Zend_Service_Audioscrobbler, Part 2

Vidyut Luther\'s Blog: Difference between \"require()\" and \"include()\" in PHP

PHP-Coding-Practices.com: Try-Catch Syntax Weirdness

Quinton Parker's Blog: Try-catch suppress?


Community Events





Don't see your event here?
Let us know!


laravel code tips list interview deployment series developer api threedevsandamaybe podcast community language conference release framework symfony introduction development zendserver

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework