DreamHost Web Hosting
Discussion Forum


Forums
   >> Programming
*Threaded Mode

Subject Disable PHP errors  
Posted byfhfadmin (DH New User )
Posted on10/09/06 01:22 PM



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.





Subject Re: Disable PHP errors new [re: fhfadmin]  
Posted byrlparker (DH DreamNinja)
Posted on10/09/06 02:22 PM



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.

--rlparker



Subject Re: Disable PHP errors new [re: rlparker]  
Posted byfhfadmin (DH New User )
Posted on10/09/06 05:42 PM



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.



Subject Re: Disable PHP errors new [re: fhfadmin]  
Posted byfeintan (DH New User )
Posted on10/09/06 06:38 PM



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.



Subject Re: Disable PHP errors new [re: feintan]  
Posted byRaz2133 (DH DreamNinja)
Posted on10/09/06 08:39 PM



In reply to:

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.


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.

http://www.wiki.dreamhost.com/index.php/PHP.ini

Mark

--
Save $50 on DreamHost hosting using promo code SAVEMONEY ( Click for promo code details )

Subject Re: Disable PHP errors new [re: fhfadmin]  
Posted byrlparker (DH DreamNinja)
Posted on10/09/06 09:37 PM



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.

--rlparker



Subject Re: Disable PHP errors new [re: rlparker]  
Posted byfhfadmin (DH New User )
Posted on10/10/06 07:25 PM



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.



Subject Re: Disable PHP errors new [re: fhfadmin]  
Posted bykchrist (DH Grizzled Veteran)
Posted on10/11/06 10:00 AM



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.



*Threaded Mode
Jump to