0

Any way to change the formatting of the text and what is displayed after a die() command? I'm currently coding all my errors using die() but I'd like to have more control over how the error message is formatted and what is displayed afterwards (like a return link for example)

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by Jerail
0

Any way to change the formatting of the text and what is displayed after a die() command? I'm currently coding all my errors using die() but I'd like to have more control over how the error message is formatted and what is displayed afterwards (like a return link for example)

One thing to bear in mind here is that die() is a language construct, not a function, but I think I see where you are going with this.

You could have a preset list of definitions for errors in the beginning of your script, then use them for your output. For example:

<?php

define("ERROR1", "Message for error number 1.");
define("ERROR2","A message with <a href='javascript:history.go(-1)'>a return to the previous page link</a> embedded.");

...

$filename = '/path/to/data-file';
$file = fopen($filename, 'r')
   or exit("unable to open file ($filename): ".ERROR2);

?>

This sounds like what you were looking for, but if I misunderstood, please feel free to clarify.

My 2¢. :)

0

One thing to bear in mind here is that die() is a language construct, not a function, but I think I see where you are going with this.

You could have a preset list of definitions for errors in the beginning of your script, then use them for your output. For example:

<?php

define("ERROR1", "Message for error number 1.");
define("ERROR2","A message with <a href='javascript:history.go(-1)'>a return to the previous page link</a> embedded.");

...

$filename = '/path/to/data-file';
$file = fopen($filename, 'r')
   or exit("unable to open file ($filename): ".ERROR2);

?>

This sounds like what you were looking for, but if I misunderstood, please feel free to clarify.

My 2¢. :)

Your 2 cents are work 2 billion :p Thanks a lot that is what i meant

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.