php - 确定图像是否存在以及是否显示图像

I have a code that shows a different image depending where on the page I am, but some places don't have an image so it displays a "no image" icon. I want to add a condition that checks if there really is an image in the given path and if returns false don't do anything. I have no idea how to do it.

This is the original code:

<?php
$search=get_search_query();
$first=$search[0];

if ($first=="#"){
      echo "<html>";
      echo "<img src='http://chusmix.com/Imagenes/grupos/".substr(get_search_query(), 1). ".jpg'>";
}
?>

What I need to know is which function do I use to get a true/false of that image path. Thanks

Use file_exists

$image_path = 'Imagenes/grupos/' . substr(get_search_query(), 1) . '.jpg';

if (file_exists($image_path)) {
    echo "<img src='http://chusmix.com/Imagenes/grupos/".substr(get_search_query(), 1). ".jpg'>";
} else {
    echo "No image";
}

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

You can use file_exists