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


 

你总是花很多时间去做一些按吧,去设计一个好的按背景全部用它吧!
  
文字可以随意更换!
  
  <?
  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是图片的文字
  
赶快试一试吧! 


申明:本区内容收集自网络,如有署名问题请速与我们(luokelong#it168.com)联系,感谢您的支持。
7上一页  下一页8

制作:罗可龙 电邮:luokelong(at)it168.com