How can the issue of incorrect HTML output be resolved when using PHP to generate image links with Lightbox2?

Issue: The problem of incorrect HTML output when generating image links with Lightbox2 using PHP can be resolved by ensuring that the image links are properly formatted with the correct attributes required by Lightbox2.

// Example PHP code snippet to generate image links with Lightbox2
echo '<a href="image.jpg" data-lightbox="image-gallery" data-title="Image Title"><img src="thumbnail.jpg" alt="Image"></a>';