In PHP templating, what strategies can be employed to handle image placeholders and prevent them from being displayed when images are not available?

When working with PHP templating, a common issue is how to handle image placeholders and prevent them from being displayed when the actual images are not available. One strategy to solve this is to check if the image file exists before displaying it, and if it doesn't, display a default placeholder image instead. This can be achieved by using the `file_exists()` function in PHP to check if the image file exists on the server before rendering it in the HTML output.

<?php
$imagePath = 'path/to/image.jpg';

if (file_exists($imagePath)) {
    echo '<img src="' . $imagePath . '" alt="Image">';
} else {
    echo '<img src="path/to/placeholder.jpg" alt="Placeholder Image">';
}
?>