我收到此错误:
syntax error, unexpected ',', expecting ']'
我的代码有问题吗?
class Represent_Graph_Adj_Matrix {
private $vertices;
private $adj_matrix = [];
public function __construct($v) {
$this->vertices = $v;
$this->adj_matrix = [[$this->vertices + 1],[$this->vertices + 1]];
var_dump($this->adj_matrix);
}
public function makeEdge($to = array(), $from = array(), $edge) {
try {
$this->adj_matrix[$to, $from] = $edge; // This is the line of the error
}
catch(Exception $e) {
echo "Vertics does not exists <br>";
}
}
public function getEdge($to, $from) {
try {
return $this->adj_matrix[$to][$from];
}
catch(Exception $e) {
echo "Vertics does not exists <br>";
}
return -1;
}
}
你们有些人可以告诉我,导致我的代码出错的原因是什么?
我在我的代码中指出了我的错误行..
拜托,我需要你的帮助.. 谢谢..