What are the best practices for serving images in PHP without triggering a download prompt?

When serving images in PHP, it's important to set the correct headers to ensure that the image is displayed in the browser instead of triggering a download prompt. To achieve this, you need to set the Content-Type header to the appropriate image type (e.g., image/jpeg, image/png) and output the image data using the appropriate PHP functions.

<?php
// Set the content type header based on the image type
header('Content-Type: image/jpeg');

// Output the image data
readfile('path/to/your/image.jpg');
?>