Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7951627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:37:04+00:00 2026-06-04T02:37:04+00:00

I am handling errors with the following script: <?php # config.inc.php // This script

  • 0

I am handling errors with the following script:

<?php # config.inc.php

// This script establishes email default settings.
// This script determines how errors are handled.

// Email Settings
$site['from_name'] = 'x'; // from email name
$site['from_email'] = 'x@x.com'; // from email address

// Just in case we need to relay to a different server, 
// provide an option to use external mail server.
$site['smtp_mode'] = 'enabled'; // enabled or disabled
$site['smtp_host'] = 'mail.x.com';
$site['smtp_port'] = null;
$site['smtp_username'] = 'admin@x.com'; 
$site['smtp_password'] = 'x';

// Error handling:
// Flag variable for site status:
$live = TRUE;

ini_set('display_errors','On');
error_reporting(E_ALL);

// Error log email address:
$admin_email = 'x@x.com';

date_default_timezone_set('America/New_York');

// Create the error handler.
function my_error_handler ($e_number, $e_message, $e_file, $e_line, $e_vars) {

    global $live, $admin_email;

    // Build the error message.
    $message = "An error occurred in script '$e_file' on line $e_line: \n<br />$e_message\n<br />";

    // Add the date and time.
    $message .= "Date/Time: " . date('n-j-Y H:i:s') . "\n<br />";

    // Append $e_vars to the $message.
    $message .= "<pre>" . print_r ($e_vars, 1) . "</pre>\n<br />";

    if ($live) { // Don't show the specific error.

        error_log ($message, 1, $admin_email); // Send email.

        // Only print an error message if the error isn't a notice.
        if ($e_number != E_NOTICE) {
            echo '<div id="Error">A system error occurred. An administrator has been notified. We apologize for the inconvenience.</div><br />';
        }

    } else { // Development (print the error).
        echo '<div id="Error">' . $message . '</div><br />';
    }

} // End of my_error_handler() definition.

// Use my error handler.
set_error_handler ('my_error_handler');

?>

If I include this script in a script with an error, the error does not get displayed. If I comment out the call to set_error_handler(), the error does get displayed. What am I doing wrong that could be causing this behavior?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:37:05+00:00Added an answer on June 4, 2026 at 2:37 am

    From the docs http://php.net/manual/en/function.set-error-handler.php

    It is important to remember that the standard PHP error handler is
    completely bypassed for the error types specified by error_types
    unless the callback function returns FALSE.

    Make your handler return FALSE

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I come across this:- PHP Error handling: die() Vs trigger_error() Vs throw Exception and
I have implemented errors handling in ASP.NET MVC site in a way like suggests
I include this simple error handling function to format errors: date_default_timezone_set('America/New_York'); // Create the
Good day! I use strategy to handle 404 errors like this: Error handling for
The below code is working great for handling errors for text fields in my
I am writing a custom error handling / reporting function for PHP file upload
I've been learning about error handling in PHP recently and came across the error_log()
I'm having a little bit of trouble implementing the following method while handling the
I've put the following code in global.asax <%@ Application Language=VB %> <script runat=server> Sub
I'm having trouble finding a simple method for handling database errors in CI. For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.