2016-08-01 79 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