我尝试使用 Google API,但在处理过程中出现错误,提示文件丢失。
在尝试访问退出的文件时,file_exists()
返回 false,不知道我哪里出错了。
注意:它在本地主机中,使用 Xampp。
文件.php:
<?php
clearstatcache();
$dir= __DIR__."\client_secret.json";
if (file_exists($dir)){
echo "exists";
} else {
echo "doesn't exist at ".$dir;
}
?>
请帮我找出哪里出错了。
最佳答案
从 dos 中对该文件夹执行 dir 操作并检查您的文件是否未命名
client_secret.json.json
Windows 文件资源管理器显示不带扩展名的文件名。您的文件名是 client_secret.json ,扩展名为 .json
<?php
clearstatcache();
$dir= __DIR__."\client_secret.json.json";
if (file_exists($dir)){
echo "exists";
} else {
echo "doesn't exist at ".$dir;
}
?>
关于php - 为什么文件存在时 file_exists() 返回 false?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48181280/