在使用PHP处理一些图像时,有时会出现诸如这样的错误:Call to undefined function imagecreate(),,导致验证码图片没有加载出来

这是由于没有安装或是没有开启php的gd库导致的问题。

PHP发生Call to undefined function imagecreate()错误的解决办法(图1)

解决办法:首先确保已经安装了php的gd库

如果没有使用:sudo apt-get install php-gd; 

1:在phpinfo 中查看Loaded Configuration File   是否存在    

于是在APACHE的配置文件httpd.conf中设置    

 比如: PHPIniDir "/usr/local/php/etc/php.ini"

          重启apache。
 (注意:确保PHPIniDir在loadModule php5_module之前)


打开php安装目录下的php.ini配置文件,找到这一行:

[plain]  view plain  copy 
  PHP发生Call to undefined function imagecreate()错误的解决办法(图2) PHP发生Call to undefined function imagecreate()错误的解决办法(图3)
  1. ;extension=php_gd2.dll  

将这一行前面的;号去掉,然后保存。这样已经开启了gd扩展库。