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?

2

4 Answers 4

2

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

error_reporting(E_ALL);
ini_set("display_errors", 1);
Sign up to request clarification or add additional context in comments.

3 Comments

Can you please show me example on ideone, I added it but no help ideone.com/1nHyyu
@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
@Check: thanks for this. IS there any way to check syntax error?
1

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

Dude function name I alraedy know, how and where to use that the issue
you need to add it at the top of your php page. I have added an example here gist.github.com/maskaravivek/10462711
thanks, does it check syntax error? is there any way?
0

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

Comments

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.

2 Comments

So I need to write everything in this sort of function?
just code to handle a 404 exception, file_exists or whatever logic you want to build in

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.