i am trying to create an ellipse using php gd library; also i want to display something under the ellipse. but the usual echo will not work with this. somebody please help me to find the reason and suggest a solution.
this is my php code
header('Content-type: image/png');
$handle = imagecreate(100, 100);
$background = imagecolorallocate($handle, 255, 255, 255);
$red = imagecolorallocate($handle, 255, 0, 0);
$green = imagecolorallocate($handle, 0, 255, 0);
$blue = imagecolorallocat开发者_开发知识库e($handle, 0, 0, 255);
for ($i = 60; $i > 50; $i--)
{
imagefilledarc($handle, 50, $i, 100, 50, 0, 90, $darkred, IMG_ARC_PIE);
imagefilledarc($handle, 50, $i, 100, 50, 90, 360 , $darkblue, IMG_ARC_PIE);
}
imagefilledarc($handle, 50, 50, 100, 50, 0, 90, $red, IMG_ARC_PIE);
imagefilledarc($handle, 50, 50, 100, 50, 90, 225 , $blue, IMG_ARC_PIE);
imagefilledarc($handle, 50, 50, 100, 50, 225, 360 , $green, IMG_ARC_PIE);
imagepng($handle);
thanks in advance
tismon
Of course it won't work. Basic HTML knowledge is necessary before gdlibrary exercises.
Open any HTML page with an image and a text, and see, how it works
If you want to output text to an image you have to use the image functions that do just that, so your first stop should be the PHP reference.
http://www.php.net/manual/en/ref.image.php
There you will find the following that allow you to output text to images : imagefttext, imagepstext, imagettftext
Check out the examples to see how to use them.
If you want to display your elipse, and some additional text (or HTML) then you need to do the following...
<img src="your-script-that-makes-an-elipse.php" alt="Elipse">
<p>This is an elipse.</p>
Essentially, you use your PHP-generated image as the source of an HTML image tag. You can also use your normal "echo" statements in this page.
<img src="your-script-that-makes-an-elipse.php" alt="Elipse">
<p><?php echo $ElipseDescription; ?></p>
You can see this in action if you view the source of the preview images here - the smaller images are created by a PHP script using GD (the script also handles caching of preview images to speed things up):
http://www.stevefenton.co.uk/Content/Gallery/Gallery/Animals/
精彩评论