【发布时间】:2011-12-13 22:01:12
【问题描述】:
谁能告诉我为什么我在尝试创建验证码时不能使用函数 imagettftext?它适用于图像字符串,但字体大小太小,所以我必须使用 imagettftext ...这是 Wamp 的问题还是它是什么?感谢您的宝贵时间!
PHP 代码(目前为止):
<?php
session_start();
header("Content-Type: image/png");
$text = $_SESSION['secure'];
$font_size = 30;
$image_width = 200;
$image_height = 40;
$image = imagecreate($image_width, $image_height);
imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 0, 0, 0);
imagettftext($image, $font_size, 0, 15, 30, $text_color, 'arial.ttf', $text);
imagepng($image);
?>
索引.php:
<?php
session_start();
$_SESSION['secure'] = rand(1000,9999);
?>
<img src="createanimage.php" />
【问题讨论】:
-
“不能使用”是什么意思?你能发布错误日志吗?