GD库在Windows下的PHP 7.4.6中无法工作。

问题描述 投票:0回答:1

当我在Windows电脑上尝试使用PHP 7.4.6中的GD库时,它显示了这个错误。

Fatal error: Uncaught Error: Call to undefined function imagecreate() in C:\Users\user\Desktop\Site\index.php:11 Stack trace: #0 {main} thrown in C:\Users\user\Desktop\Site\index.php on line 11

第11行是:

 $image = imagecreate(200,20);

完整的PHP代码是。

<?php

    $image = imagecreate(200,20);
    $background = imagecolorallocate($image,0,0,0);
    $foreground = imagecolorallocate($image, 255,255,255);

    $imagestring($image,5,5,1,"Test",$foreground);

    $header("Content-type: image/jpeg");
    $imagejpeg($image);

?>

我试着按照下面的方法来解决这个问题 指南,我取消了GD行的注释,但它仍然给我这个错误。

先谢谢你。

php gd
1个回答
0
投票

做一个 php -m 来查看PHP模块。如果你找不到 gd 然后你需要安装并启用该扩展。有很多教程在互联网上这样做


0
投票

试试这段代码。

<?php
phpinfo();

在输出结果中搜索 "GD支持". 如果没有看到或者没有启用,你需要在php.ini中启用GD--搜索 "GD支持",然后删除前面的注释,保存ini文件,重新启动IISApacheNginxwhatever服务器。

;extension=php_gd2.dll

删除前面的注释,保存ini文件,然后重新启动IISApacheNginxwhatever服务器。

© www.soinside.com 2019 - 2024. All rights reserved.