通常情况下,我使用Unix Apache htdocs
目录下的文本编辑器开发PHP网站,使用GD库的网站“开箱即用”。
然而,对于这个新客户,我被告知要将他们现有的基础设施与Netbeans一起用作在没有Apache的Windows机器上运行PHP 本地的IDE。该站点最终将部署在正常的Apache / PHP环境中,并且可以正常工作。
几乎所有东西都可以在本地运行,除了在php.ini
中启用的GD库不起作用。使用GD的代码失败并出现此错误:
Fatal error: Uncaught Error: Call to undefined function imagecreate()
当我在命令行上执行此文件时:
<?php //session_start();
print_r(get_loaded_extensions());
?>
其输出包括GD模块,因此它应该可以在代码中使用:
C:\Program Files\PHP>php 1.php
Array
(
[0] => Core
[1] => bcmath
[2] => calendar
[3] => ctype
[4] => date
[5] => filter
[6] => hash
[7] => iconv
[8] => json
[9] => mcrypt
[10] => SPL
[11] => pcre
[12] => Reflection
[13] => session
[14] => standard
[15] => mysqlnd
[16] => tokenizer
[17] => zip
[18] => zlib
[19] => libxml
[20] => dom
[21] => PDO
[22] => bz2
[23] => SimpleXML
[24] => xml
[25] => wddx
[26] => xmlreader
[27] => xmlwriter
[28] => openssl
[29] => curl
[30] => fileinfo
[31] => gd
[32] => gettext
[33] => gmp
[34] => intl
[35] => mbstring
[36] => exif
[37] => mysqli
[38] => Phar
[39] => pdo_mysql
[40] => PDO_ODBC
[41] => pdo_sqlite
[42] => soap
[43] => sockets
[44] => sqlite3
[45] => tidy
[46] => xmlrpc
[47] => xsl
[48] => xdebug
)
但是当我在PHP页面中使用相同的功能时,它不包含那么多扩展名:
Array ( [0] => Core [1] => bcmath [2] => calendar [3] => ctype [4] => date [5] => filter [6] => hash [7] => iconv [8] => json [9] => mcrypt [10] => SPL [11] => pcre [12] => Reflection [13] => session [14] => standard [15] => mysqlnd [16] => tokenizer [17] => zip [18] => zlib [19] => libxml [20] => dom [21] => PDO [22] => Phar [23] => SimpleXML [24] => xml [25] => wddx [26] => xmlreader [27] => xmlwriter [28] => cli_server [29] => xdebug )
这是否意味着php.ini
中的某些内容出错并且PHP在命令行上运行,而不是来自Netbeans?
如何在本地环境中启用GD库?
答案 0 :(得分:0)
我仍然不明白发生了什么,但重新启动开发机器后,一切都突然起作用了。加载GD库并且工作正常。这可能与添加到PATH变量的路径有关,可能不是,不确定。
此外,我一直在努力让xdebug
工作并停在断点上无济于事,但重启后它也开始工作了。