Jump to content

[SOLVED] file_exists function


Beasts

Recommended Posts

hi,

why is file_exists function acting weird?

 

my code is :

if (file_exists($filename))
{
  include($filename);
} else {
  echo("error");
}

 

the file does exist. but the error is given out.

however, when i edit the code to be if(!file_exists($filename)) then it works the way i want? isnt that the oppsite?

Link to comment
https://forums.phpfreaks.com/topic/159146-solved-file_exists-function/
Share on other sites

however, when i edit the code to be if(!file_exists($filename)) then it works the way i want? isnt that the oppsite?

 

No.  Because, in the latter if statement, it's true that the file does NOT exist.  So the include gets executed.

 

Echo out your $filename and make sure it exists.  Other than that your code looks fine.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.