通过命令行模式运行 php 脚本时出现警告

通过命令行模式运行 php 脚本时出现警告

每当我运行我的 php 命令行脚本时,在脚本实际输出到屏幕之前,php 总是返回一堆错误消息,如下所示:

PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/local/lib/php/extensions/no-debug-non-zts-20060613/gd.so' - (null) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/local/lib/php/extensions/no-debug-non-zts-20060613/mbstring.so' - (null) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/local/lib/php/extensions/no-debug-non-zts-20060613/mcrypt.so' - (null) in Unknown on line 0
PHP Warning:  Module 'memcache' already loaded in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/local/lib/php/extensions/no-debug-non-zts-20060613/mysql.so' - (null) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/local/lib/php/extensions/no-debug-non-zts-20060613/mysqli.so' - (null) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/local/lib/php/extensions/no-debug-non-zts-20060613/pdo_mysql.so' - (null) in Unknown on line 0
PHP Warning:  Module 'syck' already loaded in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/local/lib/php/extensions/no-debug-non-zts-20060613/zip.so' - (null) in Unknown on line 0
PHP Warning:  Module 'xdebug' already loaded in Unknown on line 0

但是,警告似乎并没有真正阻止我的脚本正常运行(尽管它说无法加载某些库,但我仍然可以在脚本中使用它们)。我目前正在运行通过 macports 安装的适用于 Leopard 10.5.7 的 php5.2

hidetoshi:bin jeffrey04$ port installed php5
The following ports are currently installed:
  php5 @5.2.9_0+apache2+macosx+mysql5+pear+postgresql83
  php5 @5.2.9_2+apache2+macosx+mysql5+pear+postgresql83 (active)
  php5 @5.3.0_1+apache2+macosx+mysql5+pear+postgresql83
  php5 @5.3.0_2+apache2+macosx+mysql5+pear+postgresql83

我通过这个简单的 shell 脚本切换到 php5.2

port deactivate php5 @5.3.0_2+apache2+macosx+mysql5+pear+postgresql83
port activate php5 @5.2.9_2+apache2+macosx+mysql5+pear+postgresql83

port deactivate php5-syck @0.55_2
port activate php5-syck @0.55_1

port deactivate php5-memcache @2.2.5_1
port activate php5-memcache @2.2.5_0

port deactivate php5-xdebug @2.0.5_0
port activate php5-xdebug @2.0.4_0

/opt/local/apache2/bin/apachectl restart

我做错了什么吗? 有什么方法可以删除 php 初始化期间返回的警告吗?

答案1

我在某个地方看到过类似的问题;建议先进行所有停用,然后所有激活,以防某些模块依赖于其他模块。因此,将脚本更改为:

port deactivate php5 @5.3.0_2+apache2+macosx+mysql5+pear+postgresql83
port deactivate php5-syck @0.55_2
port deactivate php5-memcache @2.2.5_1
port deactivate php5-xdebug @2.0.5_0

port activate php5 @5.2.9_2+apache2+macosx+mysql5+pear+postgresql83
port activate php5-syck @0.55_1
port activate php5-memcache @2.2.5_0
port activate php5-xdebug @2.0.4_0

/opt/local/apache2/bin/apachectl restart

答案2

您可能需要检查使用了哪个 php.ini 文件,因为在某些基于 unix 的系统下,php 为 mod_php 和 cli 接口提供了单独的 php.ini 文件。

如果是这种情况 - 您应该检查 cli php.ini 文件中的设置。

答案3

另一个想法 - 首先停用所有 php 扩展,然后停用 php,激活 php,然后激活扩展。

以防还有其他依赖项

相关内容