What alternative methods can be used to display images from a PHP script without using include or require?

When displaying images from a PHP script without using include or require, you can use the readfile() function to read the image file and output its contents directly to the browser. This method allows you to display images without the need for including or requiring external files in your script.

<?php
$imagePath = 'path/to/your/image.jpg';

// Check if the file exists
if (file_exists($imagePath)) {
    // Set the appropriate header for image display
    header('Content-Type: image/jpeg');
    
    // Output the image file contents directly to the browser
    readfile($imagePath);
} else {
    echo 'Image not found';
}
?>