I once viewed a structure or code with some PHP that had error handler (class or function) that would show an error message , The row number error, as well as the actual source code, if there is a type of error in the code, then it shows the line or some lines from the actual PHP file causing an error. It was really good, I think you never want to do this for debugging on a live production server / site, it was great and something I've never seen before.
I do not remember how I saw it or how it was done. If you have any idea about doing something, then I would love to have a nice class for handling error which makes stuff like this, please share any code, thoughts, etc. If you do Can really appreciate any help, thanks!
What you are talking about is that in PHP, you can retrieve it.
Most structures have their own way of displaying their stack traces, but basically they all use such functions.
However, what you are actually looking for is a profiler for debugger and PHP, and you
edit: < / Ul> A simple example: It is trying on cli, you should be shown this: Note that this is actually the basic use, but this is the trick. If you intend to handle
& lt; Php function myErrorHandler ($ errno, $ Errstr, $ errfile, $ errlin) {echo "[$ errno] $ errstr" PHP_EOL; Echo "line $ $ $ errfile in wrong file" PHP_EOL; $ Range = array ($ errlin - 5, $ errlin + 5,); $ Source = Explosion (PHP_EOL, file_get_contents ($ errfile)); (If $ i = $ range [0]; $ i & lt; = $ range [1]; ++ $ i) {if ($ i === count (source $ $)); If ($ i === $ intra-1) {printf ("% d |% s
bguery @ joyless: sandbox $ php debugbacktrace.php [8] undefined Variable: 33 debugbacktrace.php in undefined file 28 | $ Obj = new stud class (); 29 | $ Obj- & gt; Foo = 'bar'; 30 | 31 | // Oh, I'm calling an undefined convertible 32. Echo $ undefinedVariable; & Lt; & Lt; & Lt; & Lt; & Lt; The error here is 33. 34 $ Number = array (1,2,3,4,5); 35 ($ I = 0; $ i & lt; 5; ++ $ i) for {36 | $ Numbers [$ i] = $ i - 1; 37 | } 38 |
E_ERROR ,
E_PARSE , etc. and you need to use You may need to do more work.
Comments
Post a Comment