I am going to start introducing error handling into my structure and look for some tips on how to create it.
First, let me explain how my infrastructure is currently built:
Im, which separates the launch of the framework from the launch of the application, so any errors caused by the launch of the application must be handled specifically by the class dedicated to this.
My idea is for a class called Core_Error_exceptionwitch to set the error report to E_ALL, since my structure will be strict with regard to errors for PHP 5.3, whereas when I load my application, I will run the shutdown function in this class to restore all the default values .
What needs to be done is to capture all errors that E_*_NOTICE, and not E_*_ERROR, and then before running the application, I tell the class to stop the error capture, because it Application_Error_Exceptionwill keep track of errors.
I need a way to track all errors, including exceptions and triggers, and then before the application initializes the frame debug page.
The kind of class I was looking for looks like this:
class Core_Error_Exception
{
var $previus_error_level,$captured_contents;
private $stack_trace = array();
public function Core_Error_Exception()
{
$this->previus_error_level = error_reporting(-1);
set_error_handler(array($this,'_collect_error'));
set_exception_handler(array($this,'_collect_error'));
ob_start(array($this,'_capture'));
}
public function _collect_error($errno, $errstr, $errfile, $errline, $context)
{
$this->stack_trace[] = array(
array('name' => 'Error ID:', 'value' => $errno),
array('name' => 'Error String:','value' => $errstr),
array('name' => 'Error File:', 'value' => $errfile),
array('name' => 'Error Line:', 'value' => $errline),
array('name' => 'Context PRE:', 'value' => $context)
);
var_dump($this->stack_trace);
}
public function _capture($content,$bitfeild)
{
if($bitfeild & PHP_OUTPUT_HANDLER_START)
{
$this->captured_contents = $content;
}
if($bitfeild & PHP_OUTPUT_HANDLER_CONT)
{
$this->captured_contents .= $content;
}
if($bitfeild & PHP_OUTPUT_HANDLER_END)
{
$this->captured_contents .= $content;
}
return false;
}
}
So, what they need to do is the ability to build this class by challenging, so that any notification errors that could be triggered will be placed in the array, if the E_ERROR notification is called, it will automatically start shutdown at this point to prevent more errors from appearing .
html, , E_*_ERROR, .
, , /.
:
, trigger_error ('test', XXX); E_USER_ERROR.
PHP .., , , .