How can you handle errors related to file paths and directories when displaying images in PHP?

When displaying images in PHP, it is important to handle errors related to file paths and directories to ensure that the images are displayed correctly. One way to handle this is by using the `file_exists()` function to check if the image file exists before attempting to display it. If the file does not exist, you can display a default image or an error message instead.

$image_path = "path/to/image.jpg";

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