1

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?

user2129623
  • 2,167
  • 3
  • 35
  • 64

4 Answers4

2

To show php errors, add this one at the top of your page

error_reporting(E_ALL);
ini_set("display_errors", 1);
Ranjith
  • 2,779
  • 3
  • 22
  • 41
  • Can you please show me example on ideone, I added it but no help http://ideone.com/1nHyyu – user2129623 Apr 11 '14 at 05:55
  • @Programming_crazy I don't think, why you are putting `i` before `echo 'testing'`. Actually `error_reporting` throws only the `logical error`, not a `syntax error`. [Check out here](http://ideone.com/rwV9ne) – Ranjith Apr 11 '14 at 06:04
  • @Check: thanks for this. IS there any way to check syntax error? – user2129623 Apr 11 '14 at 17:06
1

If you want to get all PHP errors reported then use..

error_reporting(-1) 

Heres a link to the manual for error reporting

Vivek Maskara
  • 1,073
  • 11
  • 29
0

use error_reporting(-1) //This will report all types of php error.

devJsha
  • 61
  • 1
  • 9
0

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.

Guns
  • 2,678
  • 2
  • 23
  • 51