faqts : Computers : Programming : Languages : PHP : Common Problems : Tips and Tricks

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 9 people (78%) answered Yes
Recently 2 of 2 people (100%) answered Yes

Entry

How can I include an image only if the file exists?

May 31st, 2000 07:41
Ted Ciotti, Nathan Wallace, Jason Brooke


Try this code using the file_exists function:

    $photo = file_exists("/path/to/$playerid.jpg") ? "<IMG
SRC=\"/images/players/$playerid.jpg\">" : "No Photo Yet<br>\n";

    http://www.php.net/manual/function.file-exists.php