以下php代码:
<?php
class foo {
$arr = array("First","Second","Third","Fourth");
}
$obj = new foo();
echo $obj->$arr[1];
?>
生成以下错误:
Parse error: syntax error, unexpected '$arr' (T_VARIABLE), expecting function (T_FUNCTION) in /opt/lampp/htdocs/tester.php on line 3
我正在使用 php5.4 。这是什么错误?我该如何解决这个问题?