【发布时间】:2014-01-21 06:33:35
【问题描述】:
我是一名新手 PHP 开发人员,最近从 Java 开发人员那里迁移过来。对于我最初的教程,我已经开始执行网络上提供的示例、演示 PHP 程序。
我目前正在练习 PHP 框架提供给我们的 PHP 集合,特别是 SplDoubleLinkedList。
我有一个名为 Awards 的类,我试图在其中创建一个字段,类型为 SplDoubleLinkedList 的 _dll。
我的 Awards 类的源代码如下:
Awards.php
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* This is the Award class
*
* @author Razor
*/
class Award {
$_dll = new SplDoublyLinkedList();
function executeCode() {
$_dll->push(2);
$_dll->push(3);
$_dll->unshift(5);
var_dump($_dll);
}
}
这里的问题是,尽管从here 复制粘贴代码,编译器在我声明$_dll 字段的那一行返回一个语法错误。错误是,unexpected: variable $_dll. expected: function, const, use, var, }, VAR_COMMENT, static, abstract, final, private, protected, public
谁能告诉我我到底哪里出错了?尽早回复将不胜感激。提前谢谢你。
【问题讨论】:
标签: java php collections linked-list