Home arrow PHP arrow A Custom Exception Class for Dynamic Twitter Signature Images with PHP

A Custom Exception Class for Dynamic Twitter Signature Images with PHP

Welcome to part four of a five-part series on creating a dynamic Twitter signature image in PHP. In the last segment, I showed you how to implement PHP 5 exceptions as an error-handling mechanism in your signature image application. Today were going to expand upon that concept by creating a custom exception class for handling error states in our application.

  1. A Custom Exception Class for Dynamic Twitter Signature Images with PHP
  2. Examining the SignatureImage class
  3. Building a custom exception interface
  4. Building the custom exception
  5. Implementing the custom exception
By: Nilpo
Rating: starstarstarstarstar / 3
August 27, 2009

print this article



The code you have for this application so far is fully functional and includes full error-handling.  You may be wondering what the need is for a custom exception class in the first place.  So Id like to take a moment to discuss why Ive chosen to create one.

This application serves a single purpose. It accepts an input and delivers an image to the browser.  In the event of an error, the script halts execution and displays that error. 

The problem lies in this difference in output. 

The calling page is expecting an image and therefore wont display the error text.  So to make this useful, it might be a good idea to deliver the error text as an image instead. 

Since this only needs to be done in the event an exception occurs in our application, it makes sense that the code to produce this image should reside in a custom exception.  This also provides an opportunity to explore a little deeper into PHP 5s error handling capabilities.

For those readers that are just now tuning in, lets take a look at the code we have so far.  On the next page you'll see the SignatureImage class in its entirety.

>>> More PHP Articles          >>> More By Nilpo

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: