所以我把创建这个页面的 PHP 代码放到这里,然后把它放在一个新的 .php 文件中,然后把那个文件上传到这里。
我只是在屏幕上看到大量垃圾字符。有任何想法吗?
下面是完整的 PHP:
<html>
<head>
<title></title>
</head>
<body>
<?
// gif is more appropriate than jpg for this kind of image
header("Content-type: image/gif");
// both coupon.jpg and Helvetica.ttf must be located in the same directory as
// dynamic.php or these variables must be updated.
$imgname = "./coupon.jpg";
$fontname = "./Helvetica.ttf";
// read image from disk
$im = imagecreatefromjpeg( $imgname )
or die("Source coupon image has been moved or renamed! Expected coupon.jpg");
// variable allocation
$size = 11;
$textheight = 250;
$imwidth = imagesx( $im );
$black = imagecolorallocate( $im, 0,0,0 );
// create the string containing tomorrow's date
$text = "Offer expires " .
date('l\, F j\, Y', mktime(0, 0, 0, date("m") , date("d")+1, date("Y"))).".";
// learn the width of the newly allocated string
$bbox = imagettfbbox( $size, 0, $fontname, $text );
$width = $bbox[2] - $bbox[0];
// update, display, and clear from memory the newly modified image
imagettftext($im,$size,0,$imwidth/2 - $width/2,$textheight,$black,$fontname,$text);
imagegif($im);
imagedestroy($im);
?>
</body>
</html>
更新添加: 我的目标是在新页面/PHP 生成的图像上有一个谷歌分析转换脚本,这可能吗?