|
||||
|
We struggle to come up with a decent error handling function. I thought that I use a global variable $live to easily make a switch from testing to live. I will keep the function in an include file.
I kind of got there to print a "user-friendly" message when the site is live, but it messes up the whole page layout. Don't how to print the error message in the content area. How would I adjust my error handler and what would I add to "<?php require_once $content; ?>"? My error handler: <?php /*-- start output buffering--*/ ob_start(); /*-- live site --*/ $live=TRUE; /*-- error handling function giving back error number, the actual message, the error file, the error line and the variables (what are variable in this context?) --*/ function my_error_handler ($e_number, $e_message, $e_file, $e_line, $e_vars) { /*-- make $live global --*/ global $live; /*-- set error message for testing together --*/ $message="Error in file '$e_file' on line $e_line: $e_message\n"; $message.=print_r($e_vars,1); /*-- error message for live site should not give any detail about problem, just an apology --*/ if($live){ $user="We apologise for the problems on this page..."; /*-- if there are error messages print the standard user message --*/ if ($message==0){echo $user;}else{ /*-- otherwise say 'hi there' --*/ echo ('');} /*-- do it only once as user should not see the apology more than once --*/ exit(); } else { /*-- if site is in testing print the acual error messages --*/ echo '<div class="error">'.$message.'</div><br/>'; } } ob_end_flush(); /*-- as everything is defined now, set the error handler, so it's ready to be used --*/ set_error_handler('my_error_handler'); ?> Also, in the bit "if ($message==0)" I would have thought that comparing $message to 1 would have printed the user-friendly error message (as I thought 1 means that there is one or more error message). Any help appreciated. Lala |
![]() |
| Bookmarks |
| Webmaster Resources |
|
• UK WW SEO Tools • Find UK Hosts |
| The Forum Rules |
|
• Forum Rules - MUST READ |
| Site Of the Month |
![]() Nominate site of the month |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Parse error: syntax error | Bagi Zoltán | PHP Forum | 3 | 11-25-2007 04:30 PM |
| Error gone? | temi | General Webmaster Talk | 3 | 09-26-2007 12:15 PM |
| Installation - SQL error | northernwc | Boss Cart Installation Help | 12 | 09-19-2006 10:43 AM |
| 661 error | jacky820 | iG Shop | 3 | 12-17-2004 01:52 AM |
| Fatal error | pteixeira | iG Shop | 1 | 04-10-2004 01:36 AM |
| UK Webmaster World Forums - Internet marketing, web development, domain names, SEO contest and discussuons. |
| Subscribe to our feeds |