我有一个小问题,在方法中声明数组时出错了吗?
function parseJsonString($string, &$table = []) {
....
}
错误结果为"分析错误:语法错误,第10行D:''AppServ''www''test''parser.php中出现意外的'[]">
在PHP中,空数组文字是array()
而不是[]
。
如以下注释中所述,[]
在PHP 5.4及更高版本中有效。
在php中,您应该将其声明为:
function parseJsonString($string, &$table = array()) {
....
}
看看这个http://php.net/manual/en/functions.arguments.php
只有当php版本>=5.4