Page 1 of 1

file_exists bug?

Posted: Wed Dec 02, 2009 10:40 am
by Bob Kellock
$recfile = $_GET[r];
if (file_exists('CustDat/' . $recfile))
{...............

Normally works correctly but if $_GET[r] returns a null then file_exists returns True.

Seems a bit odd to me

Bob

Re: file_exists bug?

Posted: Wed Dec 02, 2009 11:31 am
by AbraCadaver
Bob Kellock wrote:$recfile = $_GET[r];
if (file_exists('CustDat/' . $recfile))
{...............

Normally works correctly but if $_GET[r] returns a null then file_exists returns True.

Seems a bit odd to me

Bob
If $recfile is empty then you are checking the dir 'CustDat/' which is a file and I assume does exist :D

Try is_file() or work on your program logic so that you don't do the check if the var is empty (makes more sense). Your code is sloppy.

-Shawn