file_exist函数不起作用

时间:2014-04-23 20:35:54

标签: php

我有一个检查移动图像是否存在的函数,如果存在,则返回true。无论我做什么,我都无法使这个功能正常工作。

public function mobileImageExist($image)
{
    $file = "images/$image";
    if(file_exists($file))
        return true;

    return false;
}

我也试过

public function mobileImageExist($image)
{
    $file = dirname(__FILE__)."/images/$image";
    if(file_exists($file))
        return true;

    return false;
}

传递给函数的$ image参数只是图像名称。例如:banner_mobile.jpg

1 个答案:

答案 0 :(得分:0)

搞定了。它最终成为另一个引用mobileImageExist函数的函数,并导致它以某种方式返回true,无论文件是否存在