Recent Blog Posts
Blogs ยป Archive for April 4th, 2006
Pretty Blue Screen
Been playing around with Zend’s framework some more and finally got annoyed enough about how exceptions are displayed to do something about it.
The code at the bottom of this post just needs including somewhere and enables a “pretty” exception handler – it’s not specific to Zend’s framework – to use it just…
<?php
// Require somewhere like index.php
require_once ‘PrettyBlueScreen.php’;
…and away you go.
The idea is not original – it’s PHP port from webpy which used code from Django – imitation and flattery.
What it does, should an uncaught exception occur;
Pretty Colours

Stack Trace

Call Arguments

Source Code Snippets

Request Information

Response Headers

At the moment it’s only for PHP 5 exceptions, although it shouldn’t be too hard to modify it to handle normal PHP errors. It probably only works with PHP 5.1+ (have only tested on 5.1.2) but some more tweaking could fix that (at least for PHP 5.0).
Important note: this is only for development – do not place on a public web server – the only information it lacks is your PIN number…
Anyway – the code;
<?php
set_exception_handler(’PrettyBlueScreen’);
function PrettyBlueScreen($e) {
$o = create_function(’$in’,'echo htmlspecialchars($in);’);
…
Sponsored Links
SitePoint Marketplace
Buy and sell Websites, templates, domain names, hosting, graphics and more.