PHP致命错误:调用未定义函数imagettftext() [英] PHP Fatal error: Call to undefined function imagettftext()

查看:608
本文介绍了PHP致命错误:调用未定义函数imagettftext()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在第29行出现错误PHP Fatal error: Call to undefined function imagettftext()?

Why am I getting the error PHP Fatal error: Call to undefined function imagettftext() on line 29?

<?php
ob_start();
session_start();

$strings = '123456789';
$i = 0;
$characters = 6;
$code = '';
while ($i < $characters)
{ 
    $code .= substr($strings, mt_rand(0, strlen($strings)-1), 1);
    $i++;
} 

$_SESSION['captcha'] = $code;

//generate image
$im = imagecreatetruecolor(124, 40);
$foreground = imagecolorallocate($im, 0, 0, 0);
$shadow = imagecolorallocate($im, 173, 172, 168);
$background = imagecolorallocate($im, 255, 255, 255);

imagefilledrectangle($im, 0, 0, 200, 200, $background);

// use your own font!
$font = 'monofont.ttf';

//draw text:
imagettftext($im, 35, 0, 9, 28, $shadow, $font, $code);
imagettftext($im, 35, 0, 2, 32, $foreground, $font, $code);     

// 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/png");
imagepng($im);
imagedestroy($im);
?>`

我的PHP信息:

推荐答案

根据

此功能需要GD库和»FreeType库.

This function requires both the GD library and the » FreeType library.

您必须在PHP构建中缺少一个或两个必需的库.

You must be missing one or both of the required libraries in your PHP build.

这篇关于PHP致命错误:调用未定义函数imagettftext()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆