我最近在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时,我会看到图像损坏的图标。我究竟做错了什么?我是个菜鸟;善良。
答案 0 :(得分:1)
php 5.1.4非常古老(2006年5月!) - 你应该升级到至少php 5.4或php 5.5(最新版)。然后,您可以按照以下configuration steps启用GD库。