The revisions let you track differences between multiple versions of a post.

Revision of PHP5 and Exception handling from Sun, 2010-10-03 17:56

PHP
Programming

 

Introduction

Recently i decided to drop PHP4 support on all of my projects. it means that i can get rid of all the workarounds and start using PHP5's new features and also push the team members to learn its new concepts until the framework becomes ready.

 

Prefeace

However upgrading several frameworks and projects with hundred thousands lines of code is not an easy task. The core should be as solid as possible. designing a solid framework require lots of planning and thinking.

In this post (This is actually a research project and should have been in Research section, but since that section is not ready yet , i'll write here for now) i want to write about PHP5's exception handling and how it can be implemented correctly. after reading dozens of articles and comments it's time to summarize things up and implement my own special version...

Understanding PHP5's exception handling

As you might already know, exception handling is nothing new. as a matter of fact almost all of the modern programming languages like Java, Python, C++, etc already support this feature much more completed than PHP. so it's a must have feature. lets see how it works.

How to integrate it

...

When should we throw exception :

  • When it's an unexpected behaviour, for example when we include a class and want to make an instance. That class should exists, and if it's there is a serious problem.
  • When it happens application can no longer work properly

Important Question

  • Should we use exception for PHP's built-in errors?
    • No, because chaning default behaviour confuses users

Resources :

Your rating: None Average: 2.4 (8 votes)