1

i have this if statement

if(file_exists( $_SERVER{'DOCUMENT_ROOT'}.$writabledir.$name) && filemtime($_SERVER{'DOCUMENT_ROOT'}.$writabledir.$name) < $olddate)  { 

if the file is there all is well but if the file is not there I get this error

 Warning: filemtime(): stat failed for /User....

I know I can do an if and then an inner if but is there a better way?

Matt Elhotiby
  • 43,028
  • 85
  • 218
  • 321

1 Answers1

0

If file_exists is returning false, then the filemtime call should never happen. && is a short-circuiting logical AND in PHP, meaning that if it doesn't need to make the second call (i.e. first part of the logical statement is false, therefore there is no way the whole statement could be true), it won't. There might be something else weird going on in your code.

CassOnMars
  • 6,153
  • 2
  • 32
  • 47