【发布时间】:2010-11-20 05:52:57
【问题描述】:
由于某种原因,下面的 PHP 代码无法运行,我无法弄清楚。
这很奇怪, file_exists 似乎没有看到该图像确实存在,我已检查以确保将一个好的文件路径插入到 file_exists 函数中并且它仍在起作用
如果我将 file_exists 更改为 !file_exists,它将返回一个存在和不存在的图像
define('SITE_PATH2', 'http://localhost/');
$noimg = SITE_PATH2. 'images/userphoto/noimagesmall.jpg';
$thumb_name = 'http://localhost/images/userphoto/1/2/2/59874a886a0356abc1_thumb9.jpg';
if (file_exists($thumb_name)) {
$img_name = $thumb_name;
}else{
$img_name = $noimg;
}
echo $img_name;
【问题讨论】:
标签: php file-exists