4

How can I prevent php error logging in php? I can print errors, but I can't disable error logging(all php errors are appended to error_log in my host). I have tried to search the net, but I haven't find anything(exept solutions which are not working for me). My function that shows errors:

function show_errors($log = false) {

    if ($log) {
      // so what here?
    }

    error_reporting(E_ALL);
    ini_set('display_errors', '1');

}

But remember. I can't use php_flags or php_values in my .htaccess file because my web server has blocked them.

7
  • Why would you want to hide errors? They're there for a reason - so you can see what's not working and fix it. Commented Dec 13, 2013 at 17:38
  • My function prints errors in the page, so i don't need error logging then, @andrewsi. Commented Dec 13, 2013 at 17:39
  • Consider it a belts-and-braces approach, in that case :) Commented Dec 13, 2013 at 17:40
  • Yea but I would use this functionality when i debug my just-coded phps. Commented Dec 13, 2013 at 17:44
  • Ask web host support to disable it manually for your domain, Since they can modify apache config Commented Dec 13, 2013 at 17:56

1 Answer 1

6

If your php.ini does not have safe_mode or open_basedir in effect, you can do this

ini_set('error_log', '/dev/null');  

You can also use .htaccess at your docroot and add

php_value error_log /dev/null 
Sign up to request clarification or add additional context in comments.

Comments

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.