What are some common mistakes to avoid when handling image output in PHP?
One common mistake when handling image output in PHP is not setting the correct content type header before outputting the image. This can lead to the image not displaying correctly in the browser. To avoid this issue, make sure to set the content type header to the appropriate image type before outputting the image data.
// Set the content type header to image type
header('Content-Type: image/jpeg');
// Output the image data
readfile('image.jpg');