草庐IT

PHP fatal error : Call to undefined function imagettftext()

coder 2023-06-13 原文

为什么我在第 29 行收到错误 PHP Fatal error: Call to undefined function imagettftext()

<?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 信息:

最佳答案

根据PHP manual entry for imagettftext() :

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

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

关于PHP fatal error : Call to undefined function imagettftext(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7290958/

有关PHP fatal error : Call to undefined function imagettftext()的更多相关文章

  1. PHP 警告 : PHP Startup: Unable to load dynamic library '\xampp\php\e xt\php_pgsql. dll - 2

    我尝试使用zend框架,但是当我通过命令提示符创建项目时,警告即将到来,警告是PHP警告:PHP启动:无法加载动态库'\xampp\php\ext\php_pgsql.dll 最佳答案 在我的案例中,我的XAMPP安装在以下路径中:C:\xampp还有当我尝试在CMD上运行以下命令时,any_drive_and_path_here>phpphpFile.php它给了我像上面这样的警告错误消息,超过15+!!!(我必须执行以下步骤来解决每个警告消息。)然后我搜索了谷歌。我想到了这个想法,无论这些模块是什么,都将被加载,只是因为php.

  2. c++ - 处理 Xlib/Xt 中的 "new top level window"事件 - 2

    因此,我需要知道何时创建顶级窗口。我在Xlib/Xt级别和不支持EWMH规范的窗口管理器上工作。我的想法是挂接到根窗口的SubstructureNotify事件。但事情并没有这么简单。问题是并非每个CreateNotify事件都对应于[b]顶级[/b]窗口的创建。所以我认为我需要做的是以某种方式测试我从事件中获得的窗口,以确认它是顶级窗口。我已经接近了,但一些虚假的窗口仍然通过我的网络。例如,在GTK应用程序中,如果您有一个下拉框并单击它,则会创建一个新窗口,我不知道如何捕捉和忽略它。这样的窗口很难与典型的顶级应用程序窗口区分开来。这是我目前所拥有的://Iamomiting(tons

  3. android - 解读Android xt_qtaguid/stats - 2

    我有一个关于Android的网络统计及其报告方式的快速问题。通过在cmd中运行此代码:adbshellcatproc/net/xt_qtaguid/stats>C:\netstats.txt"我得到一个看起来或多或少像这样的文件(为了提问我截取了一些fragment):idxifaceacct_tag_hexuid_tag_intcnt_setrx_bytesrx_packetstx_bytestx_packetsrx_tcp_bytesrx_tcp_packetsrx_udp_bytesrx_udp_packetsrx_other_bytesrx_other_packetstx_tc

  4. python - 在 Python 中,如何从 .t​​xt 文件中获取整数列表,其中空格分隔且多行以 '\r\n' 分隔的数字? - 2

    行数一开始就已知。输入文件:012345678812345670408263715..nsuchlines期望的结果:line1=[0,1,2,3,4,5,6,7,8]line2=[8,1,2,3,4,5,6,7,0]line3=[4,0,8,2,6,3,7,1,5]..linen=[n1,........n9]我现在:在每一行剥离'\r\n'的文件使用.split()获取每一行在空格和int(i)之间分隔以转换为整数代码:#Thelinesstartatthe7thbyteintheinputfile.f.seek(7)#Gettingridofthe'\r\n'lines=[lin

随机推荐