Re: PEAR Coding Standards
| From: | Aidan Lister | Date: | Tue, 04 May 2004 03:34:32 +0000 |
| Subject: | Re: PEAR Coding Standards | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-28754@lists.php.net to get a copy of this message | ||
"Justin Patrin" <papercrane@reversefold.com> wrote in message
news:20040503213821.37689.qmail@pb1.pair.com...
> Florent Monnier wrote:
>
> > Thorsten Suckow-Homberg a écrit :
> >
> >>>This is not a good idea. Hust imagine you are opening a socket, ftp
> >>>connections or anything else that works with a remote server... If the
> >>>connection times out, there will be a warning...
> >>
> >>You are right with this. But sometimes it would help more to get a
> >>PEAR_Error instead of ugly notices, warnings etc., for example when you
> >>want to access a specific function where the possibility is high that it
is
> >>not installed on every server...
> >>Use function_exists("yadayada") instead of @yadayada, that was my main
> >>intention.
> >
> >
> > Indeed, on this point there is an error in your Image_Imagick proposal
version
> > alpha 0.2 (not just one but this thread is about '@').
> >
> > In the function addUserFilter(), your include won't work in case that
> > somefile.php does not exists if you strip the '@':
> > I think you should put it back this way, for this code to work as you
expect:
> > $bCheckReq = @include_once 'somefile.php';
> > if (!$bCheckReq) {
> > //error handling
> > }
> >
> > If you really want to remove all '@' from your code, perhaps another
solution
> > would be to use if(file_exists() && is_readable()) {/*safe include*/}
>
> However, if you're relying on the include_path (as all PEAR packages
> do), then this won't work. file_exists only checks in the current
> working directory. You'd have to check everything in the include_path
> and that's something that include is already doing. Better to just use @
> and check the return value.
>
http://ircphp.com/users/imho/?file=function.file_exists_incpath.php
> --
> paperCrane <Justin Patrin>