What potential issues can arise when using the header() function in PHP to set the Content-Type to image/jpeg?

One potential issue that can arise when using the header() function in PHP to set the Content-Type to image/jpeg is that the image may not display correctly in the browser if there is any output before the header is set. To solve this issue, you can use output buffering to capture any output before sending the header.

<?php
ob_start();
// Any output before setting the header

header('Content-Type: image/jpeg');
// Output image content here

ob_end_flush();
?>