This is a discussion on PHP5 and exception handling within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hello, I'm used to exception handling in C++ or Delphi/Object Pascal and I had lotsa expectations for PHP5 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello,
I'm used to exception handling in C++ or Delphi/Object Pascal and I had lotsa expectations for PHP5 exception handling, especially since I started working on a project with MSSQL, and I need transaction support: do a few inserts and rollback the whole thing if an error occured. I might be wrong, but I searched a lot and read a lot and ran some tests, and exceptions handling in PHP5 sucks. They implemented exceptions in objects, but the core language itself doesnt throw expections. For example, a division by zero in Object Pascal will throw exception EDivisionZero or something, and most functions/objects will also throw exceptions. It's safe then to write a try .. catch block because you know you're gonna catch everything. In PHP5 it seems you have to code and check everything yourself to make sure everything throws an exception, but that defeats the whole purpose of feeling save about catching any exception. Am I completely wrong and total idiot because I don't have a clue or am I right? Is there something I'm not getting? How would you implement some clean way to handle transactions with PHP? ------- Guillaume Montreal, Canada |
|
|||
|
On Wed, 4 Aug 2004 00:21:32 -0400, "Guillaume Métayer"
<guillaumeNOmetayerSPAM@hotmail.com> wrote: >... They implemented exceptions in >objects, but the core language itself doesnt throw expections. Yes, because the focus on PHP5 was a more OO oriented class structure--that pretty much is exclusive to classes and not PHP as a whole. For more information on the significant changes in PHP5, to avoid further confusion, try reading at least one more site (if you haven't already): http://www.zend.com/php5/articles/en...p5-changes.php |