[Phpwm] unlinking files

Phil Beynon phil at infolinkelectronics.co.uk
Fri Sep 29 12:20:18 BST 2006


> Someone, quite probably Rob Allen, once wrote:
> >I've just checked our library code and we do:
> >
> >if (is_file($form_field_file) && !is_dir($form_field_file))
> >{
> >    // do stuff
> >}
> >
> >
> >I wonder what the difference between file_exists() and is_file()
> >actually is?!
>
> is_file() should return false for a directory, whereas file_exists()
> would return true for a directory.
>
> So basically:
>  is_file() == ( file_exists() && !is_dir() )
>
> Kevin

Essentially that is correct, but by using file_exists() also allows a false
to be presented for files that are inaccessible due to safe mode
restrictions unless they have been explicitly overidden, so the logic is a
tiny bit different.

There is something on php.net about file sizes over 2^32 in size but I
hardly think thats often an appropriate worry!
Anyway in what I'm doing no one could upload anything approaching that
magnitude, it wouold be rejected much earlier.

I reckon my coding bulks out by about at least a 20% load due to my paranoia
about user stupidity and hacking vunerabilities! :-)

Phil




More information about the Phpwm mailing list