Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 11th, 2004, 07:05 PM
Registered User
 
Join Date: Oct 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 8 - Reporting Fatal Errors

I would like to implement the PHP Error Handler from Chapter 8 into my website, but have been unable to get the script to work when it encounters a fatal error. The problem I have been experiencing, both locally and on my remote server, is that when PHP encounters a fatal error, it appears to stop all scripts.

I have researched elsewhere and have been unable to find any reference of PHP still executing a script after it has encountered a fatal error. I have even copied the source from www.wrox.com and placed it on my site, but still receive the same problem.

Any assistance would be greatly appreciated. Both my server and my development machine are running PHP 4.3.8. Below is my source code, in case it helps. Thanks.

--------------------------------------------------------------
function handler($error_type, $error_message, $error_file, $error_line)
{
  switch($error_type)
  {
   //fatal error
   case E_ERROR:
     echo 'Hello World';
     // send mail
     $subject = $error_type . ' on line ' . $error_line . ' in ' . $error_file;
     $content = "MY EMAIL CONTENT";
     from = 'Fatal Error @ BW';
     developerMail($subject,$content,$from);
     die();
     break;
     //end script

   case E_WARNING:
     // send mail
     $subject = $error_type . ' on line ' . $error_line . ' in ' . $error_file;
     $content = "MY EMAIL CONTENT";
     $from = 'Warning @ BW';
     developerMail($subject,$content,$from);
     break;
     //script will continue

   case E_NOTICE:
     //don't show notice errors
     break;
  }
}
error_reporting(0);
set_error_handler("handler");

//cause a fatal error
fatalerror();
--------------------------------------------------------------
NOTEā€”The script does work when it encounters a warning. My only problem is with fatal errors. Thanks again.




Similar Threads
Thread Thread Starter Forum Replies Last Post
More Errors in chapter 7..... rollercoaster BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 5 October 3rd, 2006 03:49 PM
Chapter 4 Example Code Errors beckerm13 BOOK: Professional Ajax ISBN: 978-0-471-77778-6 3 September 28th, 2006 03:40 PM
Chapter 6 Try It Out errors Voltron ASP.NET 2.0 Basics 0 August 9th, 2006 01:42 AM
Chapter 4 Errors? DRAYKKO BOOK: Beginning Java 2 3 June 1st, 2004 07:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.