我最近在我的 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 时,我看到了损坏图像的图标。我究竟做错了什么?我是菜鸟;善待。