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 7985787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:39:30+00:00 2026-06-04T11:39:30+00:00

I am running a php codeigniter based web application. I wanted to show custom

  • 0

I am running a php codeigniter based web application. I wanted to show custom error pages and custom error messages in my application.

So I extented the codeigniter’s core Exception class with my custom exception class. I added a file MY_Exceptions.php in application/core folder.

It seems like the show_error method is overwritten but the show_php_error is not overwritten by my custom class. It is still executing the show_php_error method from system/core/Exceptions.php instead of application/core/MY_Exceptions.php (my custom class).

The MY_Exceptions.php file is as below –

<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class MY_Exceptions extends CI_Exceptions
{
public function __construct()
{
    parent::__construct();
}

function show_error($heading, $message, $template = 'error_general', $status_code = 500)
{
    if($template!='error_404'){
        $template = 'custom_error_page';
        $heading = "An Error Occured";
        $message = "We're sorry, but we can not complete the action you requested. A notification has been sent to our customer service team. Please try again later.";
    }else{
        $template = 'custom_error_page';
        $heading = "404 Page Not Found";
        $message = "We're sorry, but we can not load the page you requested. A notification has been sent to our customer service team. Please try again later..";
    }
    set_status_header($status_code);

    $message = '<p>'.implode('</p><p>', ( ! is_array($message)) ? array($message) : $message).'</p>';

    if (ob_get_level() > $this->ob_level + 1)
    {
        ob_end_flush();
    }
    ob_start();
    include(APPPATH.'errors/'.$template.'.php');
    $buffer = ob_get_contents();
    ob_end_clean();
    return $buffer;
}

function show_php_error($severity, $message, $filepath, $line)
{
    $heading = "An Error Occured";
    $message = " We're sorry, but we can not complete the action you requested. A notification has been sent to our customer service team. Please try again later.";
    echo $this->show_error($heading, $message, 'custom_error_php', 404);
    exit;
}

}

  • 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-04T11:39:31+00:00Added an answer on June 4, 2026 at 11:39 am

    Why dont you just changed the “error_404.php” and “error_general.php” files in /application/errors?

    That way you can style the pages however you want, and put your generic error messages there, rather than extending a core class?

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

Sidebar

Related Questions

I am working on the development of a web based application on codeigniter. I
I have an application running with Codeigniter, its name is SAF. folder structure: /SAF/index.php
I am running PHP with CodeIgniter. My application needs to output formatted addresses throughout
I've been having a few problems running PHP-based utilities within the command line ever
I have a system running in PHP and am using CodeIgniter (if there is
I'm running XDebug on Linux CentOS. I want to profile pages on a web
I'm running php/codeigniter. could somone give me any clues?
When running PHP with Apache I know that the php core and all libraries
I am creating an intranet application in php that is running on a client's
First things first. I'm running CodeIgniter on a PHP/MySQL site. I've been tasked with

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.