【问题标题】:Fatal error: Cannot use object of type Poisson as array致命错误:不能使用 Poisson 类型的对象作为数组
【发布时间】:2015-02-12 02:56:22
【问题描述】:

大家好,我在这段代码中遇到了这个错误,我在 Markets.php 类中有这个函数

public function getUnder($line){
        $under = 0;
        for($i=0; $i<= floor($line) ;$i++){
            for ($j=0; $j<= (floor($line) - $i);$j++){
                    $under = $under + $this->poisson_tab[$i][$j];
            }
        }
        return $under;
    }

我正在尝试这样使用它:

$get_markets = new Markets($tab_poisson);

echo "Under 2.5 -> ".(1/$get_markets->getUnder(2.5))."</br>";

【问题讨论】:

  • 你能展示一下 Markets 类的代码吗?

标签: php fatal-error


【解决方案1】:

你的问题很模糊,但根据你提供的信息,我猜..

$this-&gt;poisson_tab[$i][$j] 不应该作为数组引用,它应该作为对象引用.. 像 $this-&gt;poisson_tab-&gt;$i-&gt;$j$this-&gt;poisson_tab[$i]-&gt;$j 取决于您的代码的其余部分。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-19
    • 2013-07-05
    • 2019-06-19
    • 1970-01-01
    相关资源
    最近更新 更多