我正在为一个表单使用一个简单的验证码系统。在Windows上运行正常,但在Mac上不显示。在两个系统中都启用了DG,我已经用phpinfo()检查过了。
<?php
session_start();
// generate random number and store in session
$randomnr = rand(1000, 9999);
$_SESSION['randomnr2'] = md5($randomnr);
//generate image
$im = imagecreatetruecolor(90, 32);
//colors:
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 200, 35, $black);
//path to font:
$font = 'fonts/rock-webfont.ttf';
//draw text:
//imagettftext($im, 35, 0, 22, 24, $grey, $font, $randomnr);
//imagettftext($im, 35, 0, 15, 26, $white, $font, $randomnr);
imagettftext($im, 24, 0, 12, 26, $grey, $font, $randomnr);
imagettftext($im, 24, 0, 8, 28, $white, $font, $randomnr);
// prevent client side caching
header("Expires: Wed, 1 Jan 1997 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
//send image to browser
header ("Content-type: image/gif");
imagegif($im);
imagedestroy($im);
?>更新:我使用的是安装了PHP 5.3.3版本的OS X Snow Leopard。我现在启用了错误报告,我看到了这个错误:调用未定义的函数imagettftext()。这很奇怪,因为如果我导航到函数的定义,它会将我带到GD库中的imagettftext()!
有什么建议吗?
提前谢谢。
毛罗
发布于 2011-05-13 17:38:09
如果错误为Fatal error: Call to undefined function imagettftext(),则表示未安装GD模块。
顺便说一句,请更新你的问题,澄清你想要做什么和在哪里做。“在Mac上”是什么意思?您使用的是哪种操作系统?哪个web服务器?哪个版本?哪个PHP版本?以此类推。
发布于 2012-10-07 23:16:06
雪豹上的PHP5.3.x缺少ttf (TrueType)模块
https://stackoverflow.com/questions/5989865
复制相似问题