Are there specific PHP functions or methods that can help dynamically adjust image display based on availability in a script?

When displaying images dynamically in a script, it's important to check if the image file exists before attempting to display it. This can be done using PHP functions like `file_exists()` or `is_file()`. By checking the availability of the image file, you can adjust the display logic accordingly, such as showing a default image if the requested image is not available.

$imagePath = 'path/to/image.jpg';

if (file_exists($imagePath)) {
    echo '<img src="' . $imagePath . '" alt="Image">';
} else {
    echo '<img src="path/to/default-image.jpg" alt="Default Image">';
}