Hur fungerar file_exists?

PHP

2 svar · 160 visningar · startad av Qonos

Medlem sedan sep. 2000438 inlägg
Trådstart#1

inte så här iaf :o(

<?php
if(!file_exists($row[id].".jpg"))
echo' <img src="home/'.$row[id].'.jpg" width="80" border="0" alt="" hspace="8" vspace="3"><br>';
?>

Medlem sedan okt. 20001 285 inlägg
#2

Så här kanske ?

<?
$min_bild = $row[id];

if(file_exists($min_bild.jpg")) {
echo " <img src=\"home/$min_ bild.jpg\" width=\"80\" border=\"0\" alt=\"\" hspace=\"8\" vspace=\"3\"><br>";
} else {
echo " <img src=\"home/standard.jpg\" width=\"80\" border=\"0\" alt=\"finns inte\" hspace=\"8\" vspace=\"3\"><br>";
}
?>

Medlem sedan sep. 2000438 inlägg
#3

<?
$min_bild = 'home/'.$row[id].'.jpg';

if(file_exists($min_bild)) {
echo " <img src=\"$min_bild\" width=\"80\" border=\"0\" alt=\"\" hspace=\"8\" vspace=\"3\"><br>";
} else {
echo " <img src=\"home/standard.jpg\" width=\"80\" border=\"0\" alt=\"finns inte\" hspace=\"8\" vspace=\"3\"><br>";
}
?>

fick fixa lite med det, men nu fungerar det... tackar

259 ms totalt · 4 externa anrop · v20260731065814-full.d34c6d5a
125 ms — deklarationer (db)
0 ms — hämta statistik (cache)
130 ms — hämta tråd, inlägg och bilagor (db)
125 ms — ändringar (db)