this is the code
<?php
$x = imagecreatetruecolor(250, 250);
$y = imagecolorallocate($x, 120 ,156,100);
header('Content-Type: image/jpeg');
imagejpeg($x);
?>
It is giving output as The image "http://localhost/firstprogram.php" cannot be displayed because it contains errors.
I also tried Example from https://www.php.net/manual/en/function.imagerectangle.php and it still displayed the same message.
And also can someone tell if header is necessary or not and what exactly is it used for?