2016-08-01 70 views
0

我已经编写了下面的PHP代码,以创建一个每行不同列数的动态矩阵,但PHPStorm表示行变量未定义。请帮忙。PHP中的动态矩阵

class reply 
{ 
    public $text; 
    private $row = array(array()); 
    private $rowIndex = 0; 
    private $colIndex = 0; 

    public function Add($menu) 
    { 
     $this->$row[$this->rowIndex][$this->colIndex] = $menu; 
     $this->colIndex++; 
    } 

    public function NextRow() 
    { 
     $this->rowIndex++; 
     $this->colIndex = 0; 
    } 
} 
+0

什么不行? – cmorrissey

+0

@cmorrissey PHPStorm表示行变量未定义 –

+0

您能发布确切的错误以及何时发生? – cmorrissey

回答

3

$this->$row是不正确,应该是$this->row