我有这个问题: $id是每个用户的 ID
$img = 'http://www.somesite.com/pictures/';
$no_img = 'http://www.somesite.com/pictures/default.jpg';
$slika_provera = "{$img}{$id[$i]}/t_1.jpg";
if (file_exists($slika_provera)){
$slika = $slika_provera;
} else {
$slika = $no_img;
}
无论文件是否存在,此循环始终设置$slika = $no_img
。我做错了什么?
函数 file_exists() 不适用于 URL。
查看 file_exists() 的手册,了解对 URL 执行等效的方法: http://php.net/manual/en/function.file-exists.php 特别是我使用这种方法: http://www.php.net/manual/en/function.file-exists.php#76420