php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #12972 is_file & co: no warning on non-existing file
Submitted: 2001-08-27 07:19 UTC Modified: 2002-04-10 18:22 UTC
From: advgraph at regiocom dot net Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4 OS: Any
Private report: No CVE-ID: None
 [2001-08-27 07:19 UTC] advgraph at regiocom dot net
when using the is_file function and a file is not found an error is sent back to the error log.  I expect this simply to return false in this case.  I am aware of file_exists, however in the manual:

 Returns true if the filename exists and is a regular file.

Therefore I expect this to also be testing for file existence.  I do not expect debugging output leading me to have to use @is_file and possibly miss other crucial error output.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-27 10:48 UTC] mfischer@php.net
Wrong. You use file_exists() to first determine if something exists. The name is a bit misleading, you can verify existense of files, directories and links (read: any file type). file_exists() is written to _not_ output any error. Whereas the is_*() functions are for good reason.

So, if you don't want to use file_exists(), you need to use @is_*(). This is the expected behaviour.

- Markus
 [2001-08-27 10:53 UTC] chagenbu@php.net
Actually, the last I checked, you _do_ need to use @file_exists() if you have error reporting all the way up to avoid error output. That surprised me.
 [2001-08-27 11:35 UTC] mfischer@php.net
I don't know what your 'last' is, but current CVS doesn't output anything with file_exists():

mfischer@ficken:~$ php -q
<? error_reporting(E_ALL); $bla = file_exists('sdahfw3gjkgsdgjksd'); var_dump($bla); ?>
bool(false)

No error outpout.

- Markus
 [2001-08-29 12:44 UTC] jeroen@php.net
IMHO, it would be more logic to comply to the manual in this case, so that the new is_file($f) behaves like the current:
file_exists($f) && is_file($f)

So nuke the warning on non-existing files. A non-existing file is not a file. Nor a directory, etc etc.

The change is easy, but do people agree that this change should happen?

(-> feature req)
 [2002-04-10 18:22 UTC] sniper@php.net
This has been fixed.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 13:01:29 2024 UTC