Php 静态方法未传递给另一个静态方法

Php 静态方法未传递给另一个静态方法,php,Php,我创建了一个静态方法来处理get,另一个通过get来处理错误 class Request { public static function get($key) { if (isset($_GET[$key])) { return $_GET[$key]; } } } class System{ public static function error($errorid = null) { $errors = array(

我创建了一个静态方法来处理get,另一个通过get来处理错误

class Request
{
public static function get($key)
{
    if (isset($_GET[$key])) {
        return $_GET[$key];
    }
}
}

 class System{
   public static function error($errorid = null) {

        $errors = array(
            1 => 'Product does not exist.',);

        if ($errorid != null && is_numeric($errorid) && isset($errors[$errorid])):
            echo'
                <div class="col-xs-12 col-sm-4 col-sm-offset-4 alert alert-danger alert-dismissable">
                    <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                     ' . $errors[$errorid] . '
                </div>
                ';
        endif;
    }
}

我在一个页面上回显了请求,其中显示了get编号,但在函数中我回显了$errorid,但没有显示任何内容。

代码>$errorid!=null是多余的,因为
是数字()
涵盖了这种情况。如果您传入了
$errorid=0
,这将大致等于
null
,并中断您的函数,因此您应该删除它
变量转储($errorid)表明您可能未启用错误报告。始终在开发和测试代码时
错误报告(E_ALL);ini设置(“显示错误”,1)我没有看到任何错误,但显示错误可能会揭示一些东西。我只是复制粘贴您的代码,并在查询字符串及其工作中设置error=1。获取错误报告,var转储,它等于null。所以一定是其他什么东西破坏了它。你确定错误值是通过url传递的吗
index.php?错误=1
System::error(Request::get('error'));