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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
Defend Against the Q2 Top Security Threats

Were you aware that overall malware worldwide was down a surprising 42% from Q1'18? Every quarter, the WatchGuard Threat Lab releases an Internet Security Report that analyzes the top threat trends impacting companies worldwide. Learn more by viewing our on-demand webinar today!

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?

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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Anti-Virus Apps

From novice to tech pro — start learning today.