Many people do not understand that PHP can produce non-HTML data. This is useful for generating image images. You can generate a simple ad map from the database or simply create a graphical button.
I use the TTF font in the following example
I usually name ' button.php3 ':
#######################################################
-----BUTTON.PHP3------
?
Header ("Content-type:image/gif");
if (!isset ($s)) $s = 11;
$size = Imagettfbbox ($s, 0, "fonts/times." TTF ", $text);
$DX = ABS ($size [2]-$size [0]);
$dy = ABS ($size [5]-$size [3]);
$xpad = 9;
$ypad = 9;
$im = imagecreate ($dx + $xpad, $dy + $ypad);
$blue = Imagecolorallocate ($im, 0X2C,0X6D,0XAF);
$black = Imagecolorallocate ($im, 0,0,0);
$white = Imagecolorallocate ($im, 255,255,255);
Imagerectangle ($im, 0,0, $DX + $xpad-1, $dy + $ypad-1, $black);
Imagerectangle ($im, 0,0, $dx + $xpad, $dy + $ypad, $white);
Imagettftext ($im, $s, 0, (int) ($xpad/2) +1, $dy + (int) ($ypad/2), $black, "Fonts/times." TTF ", $text);
Imagettftext ($im, $s, 0, (int) ($xpad/2), $dy + (int) ($ypad/2)-1, $white, "Fonts/times." TTF ", $text);
Imagegif ($im);
Imagedestroy ($im);
?>
#######################################################
It's important that you can't put any HTML tags in this file. There is no blank line before or after the?> tag. If you use this script to see an incomplete image, you may have mistakenly typed characters outside of the PHP tag.
The above script can be called out of the Web page by this syntax:
Note I:
Font path "/fonts/times. TTF "can be obtained from the Windows/fonts catalogue TIMS. TTF font file Copy to the directory of your site fonts can test to the performance of the Chinese users have yet to provide experience
Notice that I drew a black square and then used the white displacement to produce a 3D effect. Also Zou L method in light background but you can change the background color to dark to see the effect. The font has also done the same effect of three-dimensional.
You have to make sure that you install PHP with a set of support GD and TTF. Refer to the PHP FAQ. I suggest you copy libgd.a to/usr/local/lib and gd*.h files to/usr/local/include.
' Make install ' for Freettf Library.
Can find in this http://rover.wiesbaden.netsurf.de/~kikita/chai Httf font Oh!
Note:
The following source code improves the Benten? can be multiple lines of text display:
#######################################################
--------------button.php-----------------
?
?>
#######################################################
This can be generated by the following form:
#######################################################
----------test.php--------------------
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.