当前位置: 首页 > 图文教程 > 网络编程 > PHP > 用PHP画一个可以更换文字的按纽

PHP
IntegratedTemplate类实现BLOCK功能
IntegratedTemplate类实现HTML和PHP代码分离
PHP应用程序的性能优化
smarty学习笔记
用php实现soap通讯
smarty实例教程 ---程序设计部分
PEAR安装
Apache小技巧
如何简单使用WASP进行PHP开发(1)
如何简单使用WASP进行PHP开发(2)
php开发框架总结
php&java的简单使用
怎么样可以把 phpinfo()屏蔽掉
一些 php framework 的收集
地址的加密实现方法
实例解说php动态内容的缓冲和压缩
php开发中文件操作疑难问答
php中如何增加一个系统用户
php能检测浏览器的javascript脚本是否运行吗?
php操作文件问答

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 123 ::
收藏到网摘: n/a

你总是花很多时间去做一些按纽吧,去设计一个好的按纽背景全部用它吧!

文字可以随意更换!
   
 

以下为引用的内容:
 <?
  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是图片的文字

赶快试一试吧