Re: Re: Best Practices for Hiding Errors

From: Date: Mon, 06 Apr 2009 23:02:19 +0000
Subject: Re: Re: Best Practices for Hiding Errors
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-291146@lists.php.net to get a copy of this message
Good advice, what I usually do is a conditional to turn it all off except for a set of IP addresses that I work at. On Mon, Apr 6, 2009 at 3:52 PM, Shawn McKenzie <nospam@mckenzies.net> wrote: > George Langley wrote: >>       Hi all! Have a question about hiding PHP errors from the end user. >>       I have the following lines: >> >> $fp = fsockopen ($host, 80, $errno, $errstr, $timeout); >>       if (!$fp) { >>               // problem, put error handing code here >>       } else { >>               // success, do whatever here >>       } >> >> but if fsockopen is unsuccessful, PHP will display an error warning on the page before it >> even gets to my error handling code. >>       I found the display_errors command at: >> >> < >> http://ie.php.net/manual/en/errorfunc.configuration.php#ini.display-errors> >> >> but they give the following warning: >> >> "This is a feature to support your development and should never be used on production >> systems (e.g. systems connected to the internet)." >> >>       Am unclear what that means - is it okay to add: >> >> ini_set('display_errors','Off'); >> >> to my page, so that an end user won't ever get the warning displayed and I can deal >> with the error behind the scenes? Or is there a better way to keep PHP from writing error codes to >> the screen? >>       Thanks! >> >> George Langley    Multimedia Developer    Audio/Video Editor    Musician, Arranger, >> Composer www.georgelangley.ca >> > > You can probably do: > > $fp = @fsockopen ($host, 80, $errno, $errstr, $timeout); > // the @ suppresses the error > > However, what they mean by the "never be used on production systems" is > that display errors should not be "On" on a production system.  You > should change it to "Off" in your php.ini, or if you can't use the > ini_set() in your script. > > -- > Thanks! > -Shawn > http://www.spidean.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#291146) next »