What are the best practices for implementing a reload feature for images in PHP?

When implementing a reload feature for images in PHP, it is important to ensure that the browser cache is bypassed so that the updated image is displayed to the user. This can be achieved by appending a unique query string parameter to the image URL each time it is loaded.

<?php
$imagePath = 'image.jpg';
$timestamp = time(); // Generate a unique timestamp
$imageUrl = $imagePath . '?t=' . $timestamp; // Append timestamp as query string parameter

echo '<img src="' . $imageUrl . '" alt="Reloaded Image">';
?>