0

I am trying to dynamically set error reporting in PHP but I can't get the syntax right.

I tried :

ini_set('error_reporting',0);

and than this:

error_reporting(0);

But both are unable to stop the error reporting. Kindly tell me what mistake I am doing? Thank you.

(I am new to PHP and using this resource to learn PHP.)

EDIT: The Entire code is :

<?php

    ini_set('error_reporting',0);
    echo "hello world"
    $value = "abc";
    ?>
    <input type = "text" value = "<?php echo $value;?>">

I intentionally made a mistake in second line to study the error.

4
  • 1
    The syntax is right . Where did you put the code? Commented Sep 23, 2012 at 13:55
  • I am using the XAMPP server in my Desktop and its not working. and even in the tutorial video the syntax is not working . Here is the video : thenewboston.org/watch.php?cat=11&number=15 Commented Sep 23, 2012 at 14:00
  • In my php.ini it is set as E_ALL. Is the INI file supersedes the source file? Commented Sep 23, 2012 at 14:01
  • No, the source file supersedes the ini file. Commented Sep 23, 2012 at 14:02

2 Answers 2

3

You have "PHP Parse error" and it means PHP cannot compile your code, thus your error reporting setting will not work.

Try this:

error_reporting(0);
echo $foo; // This line produces notice about unset variable, but it is suppressed by error reporting level 0
Sign up to request clarification or add additional context in comments.

1 Comment

ok. Means since my code can not be compiled. Therefor PHP is using setting from INI file.
1

It is a syntax error. Hence no lines will be executed, so you cannot use ini_set or error_reporting.

If you are using Apache + mod_php, use .htaccess to suppress error reporting.

php_value error_reporting 0
php_flag display_errors off

In case you are using php cgi or fcgi, use a custom php.ini file.

1 Comment

Don't use .htaccess as it's runtime config.

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.