Disable PHP errors

Is there a simple way to disable php errors on the webpages of a site? From what I have read, that involves creating/modifying a phi.ini file, but I can’t find much on that for dreamhost beyond some info on increasing upload file sizes.

The process is the same for modifying the default error reporting as it is for increasing the upload file size, only the particular settings modified are different.

That said, disabling error reporting is generally a "very bad thing"tm, as it can result in masking serious problems and security risks. It is far better to address the errors themselves!

Alternatively, you could change the error reporting level to supress some warnings, if you insist on taking that approach as opposed to rectifying the conditions that causes the errors.


Good point – What I’m interested in doing is not ignoring errrors, butbetter handling them so that user does not just see see a dh fileshare path, and error message, and line number.

I’m hoping there is a simpler solution than needing to write unix scripts and run cron jobs.

phi.ini is in the server, I don’t think DH will allow it’s user to amend it as it’s control how PHP behave.

for large file u can always use FTP software.

True, you can not modify the server wide php.ini, but you can create a localised PHP install and modify it’s php.ini file.

There is a very good article in the wiki explaining how to copy the existing DreamHost PHP install over to a local directory and configure your site to use it. The article shows how to modify the settings ‘post_max_size’ and ‘upload_max_filesize’, but the same procedure can be used to modify whatever settings you desire.



Save [color=#CC0000]$50[/color] on DreamHost hosting using promo code [color=#CC0000]SAVEMONEY[/color] ( Click for promo code details )

Fair enough. I suggest you check out the PHP Manual section on Error Handling, paying special attention to the error_reporting function, as well as other pertinent information in those manual sections (check the links on the right side of the pages, if you are not familiar with the “online” PHP Manual’s layout).

Using the error_reporting function (second link above), you can “tweak” your code (see the provided examples), for a program without modifying the php.ini in use. In order to avoid having to set this value in each script, you could include it as a part of any common code that is routinely called into your scripts with “include”).

Remember, should you choose to do this, that you may remain blissfully unaware of a “borked” condition, and will most likely have to set error_reporting back on to even know what has happened if your script “breaks”.

I’m just wondering if there is a particular reason why you would choose to do this as opposed to tracking down and fixing the errors. :wink:


Thanks – It sounds like the way to go it to have a general include file at top off all pages that sets the adjustments to the defaults coming from the php.ini. That file would probably has a few other uses as well. I had started to read up on the error handling options, but wasn’t sure where to put the associated code.

For better or worse, I’m only set up to debug on my live site right now, so I want errors handled better cosmetically just in case someone stumbles in simultaneously. I also want to set up email notification of errors in case they show up later and are not detected in testing.

Recommended practice is to enable display_errors on your development site and disable it on production sites, and to always have log_errors enabled (this assumes you’re not doing development on your live site – you do have a separate development site, don’t you?). Users should never see raw error messages. The PHP documentation tells you this as well.

I handle errors and other PHP environment stuff (include_path, etc) using a single file that I include at the top of PHP pages on all my sites.

If you want useful replies, ask smart questions.