函数file_exists不起作用

时间:2014-06-15 17:43:35

标签: php

在我的webroot中,我有一个名为 exists.php 的文件,其中包含检查文件是否存在的代码:

$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>";
    };

文件 contact.php 存在,但在调用exists.php时,他回应:未找到文档
将代码更改为此时:

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

然后它回应:找到文件。

为什么这不适用于绝对路径?

1 个答案:

答案 0 :(得分:3)

file_exists()仅适用于支持stat函数的流包装器。

这些包括:

  • 文件://
  • 的ftp://
  • php:// memory
  • PHP://温度
  • 药业://
  • ssh2.sftp
  • RAR://

http://不受支持

相关问题