09-11-2019, 12:32 AM
I was able to redirect only database type error using hooks concept but does not work for general all type of error.
using below code i was able to redirect db related error. and error_get_last() always return null only
<?php
class PHPFatalError {
public function setHandler() {
// print_r(error_get_last()); //always returns null
register_shutdown_function([$this, 'handleShutdown']);
}
function handleShutdown() {
$CI =& get_instance();
$CI->load->database();
$has_error = $CI->db->error();
if ($has_error['message'] != '') {
redirect('');
}
}
}
?>
using below code i was able to redirect db related error. and error_get_last() always return null only
<?php
class PHPFatalError {
public function setHandler() {
// print_r(error_get_last()); //always returns null
register_shutdown_function([$this, 'handleShutdown']);
}
function handleShutdown() {
$CI =& get_instance();
$CI->load->database();
$has_error = $CI->db->error();
if ($has_error['message'] != '') {
redirect('');
}
}
}
?>