php - 安装 pear 时出现已弃用的错误

标签 php pear

我正在尝试使用内置的 PHP 5.3 安装在 OS X 上安装 PEAR。我这样做了:

curl http://pear.php.net/go-pear > go-pear.php
php go-pear.php

在回答了一些提示后,我开始收到大量这样的错误:

Deprecated: Assigning the return value of new by reference is deprecated in /Users/username/bin/pear/temp/PEAR.php on line 563
PHP Deprecated:  Assigning the return value of new by reference is deprecated in /Users/username/bin/pear/temp/PEAR.php on line 566

现在,我明白了这些错误的含义。我只是想隐藏它们。所以在我的 /private/etc/php.ini 文件中,我有以下内容:

error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED

这在我自己的代码中隐藏了那些相同的错误。但在 PEAR 中它没有。他们似乎正在更改 error_reporting 级别。

有什么好的方法可以解决这个问题吗?

最佳答案

@kguest

我无法在配置列表中找到“php_ini”。

@JW

我通过更改 PEAR 命令行的内部错误处理程序的行为解决了这个问题: 在文件/usr/share/pear/pearcmd.php 中,在文件底部,将 error_handler 的主体更改为:

if ($errno & error_reporting()) {
     $errortype = array (
        E_ERROR   =>  "Error",
        E_WARNING   =>  "Warning",
        E_PARSE   =>  "Parsing Error",
        E_NOTICE   =>  "Notice",
        E_CORE_ERROR  =>  "Core Error",
        E_CORE_WARNING  =>  "Core Warning",
        E_COMPILE_ERROR  =>  "Compile Error",
        E_COMPILE_WARNING =>  "Compile Warning",
        E_USER_ERROR =>  "User Error",
        E_USER_WARNING =>  "User Warning",
        E_USER_NOTICE =>  "User Notice"
    );
    $prefix = $errortype[$errno];
    global $_PEAR_PHPDIR;
    if (stristr($file, $_PEAR_PHPDIR)) {
        $file = substr($file, strlen($_PEAR_PHPDIR) + 1);
    } else {
        $file = basename($file);
    }
    print "\n$prefix: $errmsg in $file on line $line\n";
}

这将使 PEAR 命令与您的 php.ini 错误报告级别兼容。 (对 peclcmd.php 做同样的事情)

顺便说一句,这个函数用来读取一个空的配置描述符

$GLOBALS['config']->get('verbose') < 4

因此,我尝试更改 PEAR 配置中的详细级别,但它什么也没做(但是当达到这一行时会引发 fatal error )。

我不知道 PEAR 维护者在创建这个组件时是怎么想的,但他们至少可以提供一种隐藏错误的方法。

关于php - 安装 pear 时出现已弃用的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2807189/

相关文章:

php - 使用尊重/验证来验证子数组?

php - 尝试让 While 处于 while 循环中工作

php - 将 php 中的数据发送到 SQL、数据库时遇到问题

PHP - 在不运行代码的情况下检查 PHP 代码的语法错误

php - 使用 Pyrus 安装 PHP EzComponents 时出现问题

php - 带有发件人姓名的 PEAR PHP 邮件

php - 使用ajax和jquery将数组发送到codeigniter(php) Controller ,并在现有加载页面(在任何div中)上加载页面

windows - 在 Windows 7、wamp 服务器上安装 phpunit 时遇到问题

php - Windows 上的 PEAR 目录问题

php - 在 PHP 中进行 RSA 加密以在 .NET 中进行解密