好的程序员,我想在新年之前解决这个问题。我只想在照片存在时显示照片,否则使用默认照片。这是我始终正确返回“文件存在”的代码
<?php
$photolocation = '../wp-content/gallery/playerphotos/Joe Smith.jpg';
if (!file_exists($photolocation))
{
echo "File exists";
}
else
{
echo "File does not exist";
}
?>
当我更改photolocation
为:
$photolocation = '../wp-content/gallery/playerphotos/XXX Smith.jpg';
我错误地得到“文件存在”。
我不明白为什么条件 !file_exists 总是返回一个正值。