I saw various docs and threads, there are various function to do it. I put error in my code and tried those functions. But it does not show what is error and where it is.
Can some one please show me how they are to be used?
For example:
<?php
error_reporting(~0); ini_set('display_errors', 1);
i
echo "testing"
?>
Above code has two error one is undefine i and another ';' missing. How to I see these error?
-
1You're not seeing Parse error: syntax error, unexpected T_ECHO in 'file location' on line 4?kimbarcelona– kimbarcelona2014年04月11日 05:21:40 +00:00Commented Apr 11, 2014 at 5:21
-
possible duplicate of How do I enable error reporting in PHP?Shankar Narayana Damodaran– Shankar Narayana Damodaran2014年04月11日 05:25:14 +00:00Commented Apr 11, 2014 at 5:25
4 Answers 4
To show php errors, add this one at the top of your page
error_reporting(E_ALL);
ini_set("display_errors", 1);
3 Comments
i before echo 'testing'. Actually error_reporting throws only the logical error, not a syntax error. Check out here If you want to get all PHP errors reported then use..
error_reporting(-1)
Heres a link to the manual for error reporting
3 Comments
use error_reporting(-1) //This will report all types of php error.
Comments
You can use an Exception Handler using set_error_handler('exceptionHandler function');
Here is what is use
if (!function_exists('exceptionHandler')) {
function exceptionHandler($severity, $message, $file, $line)
{
if ($severity == E_STRICT) {
return;
}
// code logic to handle or display exceptions
}
}
This would be the way you can have control over handling exceptions.