简体   繁体   中英

function file_exists does not work

In my webroot, i have a file called exists.php in which is this code to check if a file exists:

$filename = 'http://www.domain.nl/contact.php';
if (file_exists($filename))
    {
        echo "Document ".$filename." found...<br><br><br>";
    }
    else
    {
        echo "Document ".$filename." not found...<br><br><br>";
    };

The file contact.php DOES exist but when calling exists.php he echoes: Document not found
When changing code to this:

$filename = 'contact.php';
if (file_exists($filename))
    {
        echo "Document ".$filename." found...<br><br><br>";
    }
    else
    {
        echo "Document ".$filename." not found...<br><br><br>";
    }; 

Then it echoes: Document found.

Why does this not work with an absolute path?

file_exists() only works on stream wrappers that support the stat function.

These include:

  • file://
  • ftp://
  • php://memory
  • php://temp
  • phar://
  • ssh2.sftp
  • rar://

http:// is not supported

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM