I need an include function / statement that will include a file only if it exists. Is there one in PHP?
include
You might suggest using @include bu
@include
function get_image($img_name) { $filename = "../uploads/" . $img_name; $file_exists = file_exists($filename); if ($file_exists && !empty($img_name)) { $src = ''; } else{ $src = ''; } return $src; } echo get_image($image_name);