PDA

View Full Version : using include() in a die() statement ?



mlk
August 18th, 2008, 06:20 AM
Hello peeps.

I've done a tiny bit of research and can't seem to find a way to combine the usefulness of the die() method (which interrupts your script if something screwed up) and that of the include.

I'm trying to create a better-looking error output (the usual mysql jibberish is confusing for the non-programmers), yet the die() methods only seems to output text to the browser.


Any help ?

(btw, I don't want to code a whole webpage inside of the die() using die("<html><head>....</body></html>")

evildrummer
August 18th, 2008, 07:19 AM
include_once 'error.php'; // Sets a variable and calls die OR sets a variable and do die($error);

/*******************
OR
*******************/

$errorPage = file_get_contents('errors.html');
die($errorPage);

mlk
August 18th, 2008, 07:28 AM
nifty

Icy Penguin
August 18th, 2008, 09:24 PM
I just use my own templating system - which uses output buffering and just some custom error handlers, works great for me so far.

Not sure what the die() would get you, but in my code I'll have something like this:



<?php
if($something_terrible_gone_wrong) {
trigger_error("This has happened", 1024);
}
?>


And that executes my error handler which calls a die() or redirect to an error page, whatever.