button1.php
来自「《php程序设计》的配套源码 《php程序设计》的配套源码 《php程序」· PHP 代码 · 共 19 行
PHP
19 行
<?php
$font = 'times';
if (!$size) $size =12;
$im = ImageCreateFromPNG('button.png');
// calculate position of text
$tsize = ImageTTFBBox($size, 0, $font, $text);
$dx = abs($tsize[2]-$tsize[0]);
$dy = abs($tsize[5]-$tsize[3]);
$x = (ImageSx($im)-$dx)/2;
$y = (ImageSy($im)-$dy)/2 + $dy;
// draw text
$black =ImageColorAllocate($im, 0, 0, 0);
ImageTTFText($im, $size, 0, $x, $y, $black, $font, $text);
header('Content-Type:image/png');
ImagePNG($im);
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?