PHP5 and exception handling

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 ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-04-2004
Guillaume Métayer
 
Posts: n/a
Default PHP5 and exception handling

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


Reply With Quote
  #2 (permalink)  
Old 08-04-2004
eclipsboi
 
Posts: n/a
Default Re: PHP5 and exception handling

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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:37 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0