Should functions raise warning or not?
File system functions fopen(), stat(), is_dir(), is_file(), etc
are designed to raise warnings for non-existing file/path for
histrical reason(?) There are many functions behave this way.
Is there good reason for warning? Even if functions return false
for errors?
If "false" indicate error, returning "false" is enough. Scripts
should handle "false" anyway. Therefore, if the behavior is
changed, impact for existing scripts is minimum.
I put @ before functions like fopen(), is_dir() and I always feel
this isn't the way should be.
It may be better to have clear guideline for error messages for
both script coders and module developers.
--
Yasuo Ohgaki
sniper@php.net wrote:
> ID: 14294
> Updated by: sniper
> Reported By: mike@hbhosting.com
> Status: Bogus
> Bug Type: Filesystem function related
> Operating System: FreeBSD 4.3
> PHP Version: 4.1.0
> New Comment:
>
> (or using @ in front of the function)
>
>
> Previous Comments:
> ------------------------------------------------------------------------
>
> [2001-11-30 02:42:49] sniper@php.net
>
> Warnings can be supressed by setting error_reporting correctly.
> Not a bug.
>
>
> ------------------------------------------------------------------------
>
> [2001-11-29 21:28:20] mike@hbhosting.com
>
> In PHP 4.1 RC3 (non CVS release), the is_dir() function causes a warning that says "stat
> failed on /your/path" if the path does not exist.
>
> This was causing havok with scripts of mine that relied on no output for errors.. Of course I
> just suppressed the message, but it really shouldnt be there. The function is designed to check for
> an existing dir, it should work without warnings!
>
> Hopefully this can be fixed in the next release.
>
> On a side note, PHP 4.1 (CVS version) does not install under FreeBSD 4.3. However the version
> available at http://www.php.net/~zeev/php-4.1.0RC3.tar.gz
> does work!
>
> Thanks guys.....
>
> ------------------------------------------------------------------------
>
>
>
> Edit this bug report at http://bugs.php.net/?id=14294&edit=1
>
>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
Thread (14 messages)