I'm just trying to make a rectangle appear and I'm using the code (only a variable name change and a color change were made) example in the Core PHP book I bought:
<?php
$image = imagecreate(200,200);
$buttoncolor = imagecolorallocate($image,191,241,113);
imagefill($image, 0, 0, $buttoncolor);
imagefilledrectangle($image, 10, 10, 90, 90, $buttoncolor);
header("Content-type: image/png");
imagepng($image);
?>
When I choose the 'Run and redirect output to file' option on my IDE, then click the HTML file on the desktop it creates, I get the following output: ‰PNG (and a square character--not the rectangle). I've also tried <img src>ing the PHP file in a separate HTML file, but I've had no success. I've also tried different image file-types, but that doesn't work.
Please help me.
Thanks a lot.
<?php
$image = imagecreate(200,200);
$buttoncolor = imagecolorallocate($image,191,241,113);
imagefill($image, 0, 0, $buttoncolor);
imagefilledrectangle($image, 10, 10, 90, 90, $buttoncolor);
header("Content-type: image/png");
imagepng($image);
?>
When I choose the 'Run and redirect output to file' option on my IDE, then click the HTML file on the desktop it creates, I get the following output: ‰PNG (and a square character--not the rectangle). I've also tried <img src>ing the PHP file in a separate HTML file, but I've had no success. I've also tried different image file-types, but that doesn't work.
Please help me.
Thanks a lot.