Please wait for 15 seconds...

Thursday, 17 January 2013



Today I will tell you how to pop custom warning/error message in Codeigniter. Few days ago I was working on a project in codeigniter and I needed to show some custom warning messages on user interface so I dig back into Codeigniter and found something that I would like to share with you.

It is just few lines of code that you should put on your main controller so you can call it any where in your controller and also you can use it in any of your model by putting this code in main model.


For main controller:

public function custom_error($severity, $message){
$debug_data = debug_backtrace();

_exception_handler($severity, $message, $debug_data[0]['file'], $debug_data[0]['line']);
}

Now we can call it in any controller using below syntax.

$this->custom_error('PHP error', 'Some PHP error occured.');

Same in the main model:

public function DB_custom_error($severity, $message){
$debug_data = debug_backtrace();

_exception_handler($severity, $message, $debug_data[0]['file'], $debug_data[0]['line']);
}

I hope it helped you, good luck!!

Posted by Atul Prasad Gupta

2 comments:

  1. this is really a mind blowing information and a good thing to learn here check this one also php web developer thanks for sharing..

    ReplyDelete
    Replies
    1. Thanks James. You can subscribe my Facebook or Google Plus page for more latest info

      Delete

Subscribe Techsirius

Techsirius on Facebook