How do I change error_reporting in PHP on the server?

I am using a shared server. Am I still able to change the PHP error_reporting value?

If yes what is a safe way to do this so that it does not effect others on the same server?

Who is Participating?
gamebitsConnect With a Mentor Commented:
If you do not have access to the php.ini file you can always do it at the beginning of the script(s)

error_reporting(0); //will not display the errors on the webpage
error_reporting(E_ALL); //to show everything
iDeejAuthor Commented:
Thanks gamebits

I also want to set display_errors to Off

I read that when the page crashes then using the method you've shown will not work and errors will display. Is this correct?

You will end up with a blank page if the script encounter a fatal error.
Protect Your Employees from Wi-Fi Threats

As Wi-Fi growth and popularity continues to climb, not everyone understands the risks that come with connecting to public Wi-Fi or even offering Wi-Fi to employees, visitors and guests. Download the resource kit to make sure your safe wherever business takes you!

iDeejAuthor Commented:
What about if I had a parse error? I assume that the script would not run and the parse error would be displayed.

Is the only way to stop that to change display_errors in the php.ini file?

Is there anything I can put in .htaccess to get around this?

rjdownConnect With a Mentor Commented:
display_errors should always be set to "on" on a development server, and "off" on a production server. Use error logs if you need to find out where your page died on a live site!

If you want to use .htaccess to control this, use

php_flag display_errors off (or on, obviously)
iDeejAuthor Commented:
Thanks for your help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.