PHPgraphlib PHP警告count()参数必须是数组或对象(第926行)

zed5wv10  于 11个月前  发布在  PHP
关注(0)|答案(1)|浏览(59)

我使用PHPgraphlib很多年了,喜欢它生成一个可靠的图像,而不是一些花哨的JavaScript东西。现在自从更新到PHP7,它在原始代码的第926行呈现log-error:

PHP Warning: count(): Parameter must be an array or object that implements Countable in ./phpgraphlib.php on line 926, referrer ...

字符串
第926行:

protected function displayErrors() 
    {
        if (count($this->error) > 0) {
            $lineHeight = 12;
            $errorColor = imagecolorallocate($this->image, 0, 0, 0);
            $errorBackColor = imagecolorallocate($this->image, 255, 204, 0);
            imagefilledrectangle($this->image, 0, 0, $this->width - 1, 2 * $lineHeight,  $errorBackColor);
            imagestring($this->image, 3, 2, 0, "!!----- PHPGraphLib Error -----!!",  $errorColor);
            foreach($this->error as $key => $errorText) {
                imagefilledrectangle($this->image, 0, ($key * $lineHeight) + $lineHeight, $this->width - 1, ($key * $lineHeight) + 2 * $lineHeight,  $errorBackColor);  
                imagestring($this->image, 2, 2, ($key * $lineHeight) + $lineHeight, "[". ($key + 1) . "] ". $errorText,  $errorColor);  
            }
            $errorOutlineColor = imagecolorallocate($this->image, 255, 0, 0);
            imagerectangle($this->image, 0, 0, $this->width-1,($key * $lineHeight) + 2 * $lineHeight,  $errorOutlineColor);     
        }
    }


我试图取消注解,但它在第271行抛出了另一个错误

//display errors
        $this->displayErrors();


我对PHP和MySQL做了很多,但这超出了我业余的知识。欢迎任何帮助!除了这个错误,phpgraphlib仍然像一个魅力一样工作。我使用了这个错误,因为我在phpgraphlib上找不到任何搜索这个错误的东西。参考答案肯定欢迎。
万分感谢!

eufgjt7s

eufgjt7s1#

@aynber评论- adding =[] to protected $error;第137章做了一件事新的一行写着
第一个月

相关问题