加入收藏 | 设为首页 | 会员中心 | 我要投稿 汽车网 (https://www.0577qiche.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

用PHP画一个能更换文字的按纽

发布时间:2023-10-31 09:58:35 所属栏目:PHP教程 来源:
导读:你总是花很多时间去做一些按纽吧,去设计一个好的按纽背景全部用它吧!

文字可以随意更换!

以下为引用的内容:
<?
Header( "Content-type: image/gif");
if(!isset($s)) $s=11;
//times.tif可以是你喜欢的
你总是花很多时间去做一些按纽吧,去设计一个好的按纽背景全部用它吧!

文字可以随意更换!

以下为引用的内容:
<?
Header( "Content-type: image/gif");
if(!isset($s)) $s=11;
//times.tif可以是你喜欢的任何字体
$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);
//设定R,G,B
$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);
?>

重要的是你不能在这段代码中加入任何的HTML标记,尤其不允许在<? and ?> 当中加入!
调用时写下面的代码:

<IMG SRC="button.php3?s=36&text=PHP is Cool">

s是图片的大小 text是图片的文字

赶快试一试吧

(编辑:汽车网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章