首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Mac上未显示php GD captcha图像

Mac上未显示php GD captcha图像
EN

Stack Overflow用户
提问于 2011-05-13 17:27:03
回答 2查看 2.5K关注 0票数 0

我正在为一个表单使用一个简单的验证码系统。在Windows上运行正常,但在Mac上不显示。在两个系统中都启用了DG,我已经用phpinfo()检查过了。

代码语言:javascript
复制
<?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()!

有什么建议吗?

提前谢谢。

毛罗

EN

回答 2

Stack Overflow用户

发布于 2011-05-13 17:38:09

如果错误为Fatal error: Call to undefined function imagettftext(),则表示未安装GD模块。

顺便说一句,请更新你的问题,澄清你想要做什么和在哪里做。“在Mac上”是什么意思?您使用的是哪种操作系统?哪个web服务器?哪个版本?哪个PHP版本?以此类推。

票数 2
EN

Stack Overflow用户

发布于 2012-10-07 23:16:06

雪豹上的PHP5.3.x缺少ttf (TrueType)模块

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5989865

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档