Re: Re: Silencing @

From: Date: Mon, 31 Oct 2005 13:34:53 +0000
Subject: Re: Re: Silencing @
References: 1 2  Groups: php.pear.qa 
Request: Send a blank email to pear-qa+get-3204@lists.php.net to get a copy of this message
re Helgi Þormar wrote:
On Mon, 31 Oct 2005 13:53:52 +0100, bertrand Gugger wrote:
Bonjour, This thema started wirh an IRC discussion about the use of error silencing @. The case was an optional include in some package ("some" = I don't remember which one but a few do/need that) It has an optional feature, just conditioned by the existence of a potential include 'there/option.php'. Naturally, the package will use include or include_once as it's not fatal that 'there/option.php' does not exist: require_once 'there/option.php'; if (class_exist('option') { ... // skipped the '_' <==> '/' translation to be short
Maybe I have to introduce people to file_exists ? People should always use file_exists when they are doing some kind of a driver approach and the driver might not be there (MDB2 and its drivers is one good example, it handles that nicely) Think we should rather focus on that kind of way rather than having some obscure error reporting magic :) - Helgi yes, the first example is surely a bad one
(even if you can find it a couple of occurences in pear) Some packages we well know uses the safer mechanism you quote And I think, no care if it's a little loose in performance, those optional includes are made only once, if well designed :) That was an example only, the second one is more possible as php doesn't offer a way to see if a session was started (or I missed it, certainly) I want to propose that @ get forbidden, the wiser the ways, the better it is. (especially if it focuses on the right positive aspect and not doing it by some error trapping) Now, I forgot to mention the other way to silence the errors, the way pear installer uses, * set_error_handler*( ) A @ is limited to the silenced expression,* set_error_handler*() applies to the whole, what can be very painfull if ill used. I think several related problems were trapped in the installer, but I'm still unsure. *set_error_handler*() should perhaps be wrapped in a global pear control... a+ -- bertrand "toggg" Gugger

« previous php.pear.qa (#3204) next »