How can one check the existence of a file in PHP when dealing with images in a forum setting?

When dealing with images in a forum setting in PHP, you can check the existence of a file by using the `file_exists()` function. This function takes the file path as an argument and returns true if the file exists, and false otherwise. You can use this function to ensure that the image file exists before displaying it on the forum.

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

if(file_exists($image_path)) {
    // Display the image
    echo '<img src="' . $image_path . '" alt="Image">';
} else {
    // Display a placeholder image or error message
    echo '<img src="placeholder.jpg" alt="Image not found">';
}