What are the best practices for embedding PHP-generated images in HTML using the IMG tag?

When embedding PHP-generated images in HTML using the IMG tag, it is important to set the correct content type header in the PHP script to ensure that the browser recognizes the response as an image. Additionally, the IMG tag should point to the PHP script that generates the image.

<?php
header("Content-type: image/png");
$image = imagecreate(200, 200);
$bgColor = imagecolorallocate($image, 255, 255, 255);
$textColor = imagecolorallocate($image, 0, 0, 0);
imagestring($image, 4, 50, 100, "Hello World", $textColor);
imagepng($image);
imagedestroy($image);
?>
```

```html
<!DOCTYPE html>
<html>
<head>
    <title>PHP Generated Image</title>
</head>
<body>
    <img src="generate_image.php" alt="Generated Image">
</body>
</html>