What is the best practice for handling alternative paths for images that cannot be found on the server in PHP?

When an image cannot be found on the server, it is best practice to display a default image or a placeholder instead of showing a broken image icon to the user. This can help improve the user experience and prevent confusion. One way to handle this in PHP is to check if the image file exists on the server using the `file_exists()` function, and if it does not exist, display a default image.

<?php
$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">';
}
?>