Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

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



Report this thread to moderator Post Follow-up to this message
Old Post
Guillaume Métayer
08-04-04 08:55 AM


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/e...hp5-changes.php


Report this thread to moderator Post Follow-up to this message
Old Post
eclipsboi
08-04-04 08:55 AM


Re: PHP5 and exception handling
This response is a little dated from your original post, but the answer is '
Yes, that is right.'

Exception handling in PHP5 works fine, but you can't "catch" the typical err
ors raised by PHP's built-in functions. So you can implement the throwing of
 exceptions in your own classes and other libraries, but that's about it.

Too bad there wasn't an easy way for the PHP crew to implement errors wrappe
d in exceptions of some sort.

Report this thread to moderator Post Follow-up to this message
Old Post
ybakos
07-04-06 04:10 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:33 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.