How can a PNG image created with PHP GD be saved to the hard drive?

To save a PNG image created with PHP GD to the hard drive, you can use the `imagepng()` function provided by the GD library. This function takes the image resource and the file path where you want to save the image as parameters. Make sure the directory where you want to save the image has the necessary write permissions.

// Create a PNG image with PHP GD
$image = imagecreate(200, 200);
$bg_color = imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 0, 0, 0);
imagestring($image, 5, 50, 50, 'Hello, World!', $text_color);

// Save the image to the hard drive
$image_path = 'path/to/save/image.png';
imagepng($image, $image_path);

// Free up memory
imagedestroy($image);