Home > Backend Development > PHP Tutorial > How to get error information in php, get error information in php_PHP tutorial

How to get error information in php, get error information in php_PHP tutorial

WBOY
Release: 2016-07-13 09:46:18
Original
854 people have browsed it

How to get error information in php, get error information in php

The example in this article describes how to get error information in php. Share it with everyone for your reference. The details are as follows:

function error_reg(){
 $ar=array(
  E_ERROR => 'error',
  E_WARNING => 'warning',
  E_PARSE =>'prase',
  E_NOTICE => 'notice'
 );
 register_shutdown_function(function() use ($ar){
  $ers=error_get_last();
  if($ers['type']!=8 && $ers['type']){
   $er=$ar[$ers['type']].$ers['type'].': '.' '.$ers['message'].' => '.$ers['file'].' line:'.$ers['line'].' '.date('Y-m-d H:i:s')."\n";
   error_log($er,3,'/tmp/php_error.log');
  }
 });
 set_error_handler(function($a,$b,$c,$d) use ($ar){
  if($a!=8 && $a){
   $er=$ar[$a].$a.': '.$b.' => '.$c.' line:'.$d.' '.date('Y-m-d H:i:s')."\n";
   error_log($er,3,'/tmp/php_error.log');
  }
 },E_ALL ^ E_NOTICE);
}

Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1034254.htmlTechArticleHow to get error information in php, how to get error information in php. This article describes how to get error information in php. Share it with everyone for your reference. The details are as follows: function error_reg(){...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template