0

OKプログラマー、新年の前にこれを理解したいと思います。写真が存在する場合にのみ表示したいのですが、そうでない場合はデフォルトの写真を使用します。これが常に正しく「FileExists」を返す私のコードです

<?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が常に正の値を返す理由がわかりません。

4

1 に答える 1

1

それは次のようになります。

<?php 
    $photolocation = '../wp-content/gallery/playerphotos/XXX Smith.jpg';

    if (file_exists($photolocation))
    {
        echo "File exists";
    }
    else
    {
        echo "File does not exist";
    }
?>
于 2011-12-31T22:26:40.687 に答える