首页 > 解决方案 > file_exists() 从 phpunit 执行时有效,但不是从网页执行

问题描述

我在网络共享位置上有一个文件,我想用 PHP 以编程方式检查它是否存在。

从 PhpUnit 运行时,它工作正常。我的最小测试是:

public function testBackupFileExists () {
  $backup_pname = 'R:\myFolder\mySubFolder\myFile.csv';
  $this->assertTrue (file_exists ($backup_pname), "File $backup_pname not found");
}

从我的 localhost 从 Web 界面运行时,file_exists()返回 false...

它们都使用相同版本的 PHP (7.4.1),并且都在同一台机器上执行。我也尝试运行clearstatcache(),但它不起作用。

标签: phpwindowsphpunitfile-exists

解决方案


推荐阅读