PHP
  Home arrow PHP arrow Page 3 - Error Handling In PHP (part 2)
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Error Handling In PHP (part 2)
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 10
    2002-04-09

    Table of Contents:
  • Error Handling In PHP (part 2)
  • Raising Hell
  • Rolling Back
  • Turning Up The Heat
  • Of Form And Function
  • Buffer Zone
  • Back To Class
  • Endgame

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Error Handling In PHP (part 2) - Rolling Back


    (Page 3 of 8 )

    PHP also comes with a restore_error_handler() function, which allows you to restore the previous error handler. This is useful if you need to switch between handlers in a single script. Consider the following simple example, which demonstrates:

    <?php // custom error handler function eh($type, $msg, $file, $line, $context) { echo "This is the custom error handler speaking"; } // trigger a warning // this will be caught by the default handler // since nothing else has been defined trigger_error("Something bad happened", E_USER_WARNING); // define a new handler set_error_handler("eh"); // trigger another warning // this will be caught by the custom handler trigger_error("Something bad happened", E_USER_WARNING); // rollback to default handler restore_error_handler(); // trigger another warning // this will be caught by the default handler trigger_error("Something bad happened", E_USER_WARNING); ?>
    Here's what the output looks like:

    Warning: Something bad happened in /usr/local/apache/htdocs/x2.php on line 12 This is the custom error handler speaking Warning: Something bad happened in /usr/local/apache/htdocs/x2.php on line 26

    More PHP Articles
    More By icarus, (c) Melonfire


     

       

    PHP ARTICLES

    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT