繁体   English   中英

如何在PHP 5.1.4中启用GD?

[英]How do I enable GD in PHP 5.1.4?

我最近在Win 7机器上重新安装了PHP。 这样,我从PHP 4升级到PHP 5.1.4。 GD功能不再起作用。 我取消对php.ini中的php_gd2.dll行的注释:

;extension=php_fdf.dll
;extension=php_filepro.dll
extension=php_gd2.dll      <-- This line was originally commented
;extension=php_gettext.dll
;extension=php_ifx.dll

但这并不能解决问题。 phpinfo()这样说关于gd:

GD Support  enabled  
GD Version  bundled (2.0.28 compatible)  
FreeType Support  enabled  
FreeType Linkage  with freetype  
FreeType Version  2.1.9  
T1Lib Support  enabled  
GIF Read Support  enabled  
GIF Create Support  enabled  
JPG Support  enabled  
PNG Support  enabled  
WBMP Support  enabled  
XBM Support  enabled  

这是myimage.htm:

<IMG SRC="myiamge.php" BORDER="1"> 

这是myimage.php:

<?php
$my_img = imagecreate( 200, 80 );
$background = imagecolorallocate( $my_img, 0, 0, 255 );
$text_color = imagecolorallocate( $my_img, 255, 255, 0 );
$line_color = imagecolorallocate( $my_img, 128, 255, 0 );
imagestring( $my_img, 4, 30, 25, "test", $text_color );
imagesetthickness ( $my_img, 5 );
imageline( $my_img, 30, 45, 165, 45, $line_color );
header( "Content-type: image/png" );
imagepng( $my_img );
imagecolordeallocate( $line_color );
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy( $my_img );
?>

当我将浏览器指向myimage.htm时,我看到损坏的图像图标。 我究竟做错了什么? 我是菜鸟 善待。

php 5.1.4非常古老(2006年5月!)-您应该至少升级到php 5.4或php 5.5(最新)。 然后,您可以按照以下配置步骤来启用GD库。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM