Latest News

Home » PHP程式設計教學 » 要如何配置GD庫?(PHP程式設計問題與答覆)

要如何配置GD庫?(PHP程式設計問題與答覆)

PHP程式設計問題諮詢:
我想要如何配置GD庫,其方法為何?

———————————————————
PHP程式設計問題回覆:
您要如何配置GD庫,可以參考以下的範例:

1:用dos命令(也可以手動操作,拷貝dlls檔夾裏所有dll檔到system32目錄下) copy c:phpdlls*.dll c:windowssystem32
2:打開php.ini
設置extension_dir = "c:/php/extensions/";
3:
extension=php_gd2.dll;把extension前面的逗號去掉,如果沒有php_gd2.dll,php_gd.dll也一樣,保證確實存在這一檔c:/php/extensions/php_gd2.dll
4:運行下面程式進行測試
<?php
Ob_end_flush();
//注意,在此之前不能向流覽器輸出任何資訊,要注意是否設置了 auto_prepend_file.
header ("Content-type: image/png");
$im = @imagecreate (200, 100)
    or die ("無法創建圖像");
$background_color = imagecolorallocate ($im, 0,0, 0);
$text_color = imagecolorallocate ($im, 230, 140, 150);
imagestring ($im, 3, 30, 50,  "A Simple Text String", $text_color);
imagepng ($im);
?>

———————————————————————-

About

發佈留言