3
我的IDE是否顯示在這一行我的PHP文件的「解析錯誤」:解析錯誤PHP
變量$肉=新類別(無肉肉,1);
我試圖做這行代碼的工作:
return parent::displayData($viewData);
而且$ViewData
需求是Category
對象的數組。
我的語法在哪裏讓我失望?
以下是完整的文件:
class CategorySelect extends BaseSelect {
static $template = 'select_multiple_template.php';
public static function display() {
var $meat = new Category(Meat-Free Meat, 1);
var $dairy = new Category(Dairy-Free dairy, 2);
var $confectionery = new Category(Confectionery, 3);
var $baking = new Category(Baking, 4);
var $dessert = new Category(Dessert, 5);
var $viewData = array($meat, $dairy, $confectionery, $baking, $dessert);
return parent::displayData($viewData);
}
}
class Category {
function Category($name, $id) {
$this->name = $name;
$this->id = $id;
}
}
這裏是它擴展抽象類:
interface iSelect {
public static function display();
}
abstract class BaseSelect implements iSelect {
static $template = 'select_template.php';
public static function displayData($viewData) {
if (class_exists('View')) {
$templatePath = dirname(__FILE__) . '/' . static::$template;
return View::render($templatePath, $viewData);
}
else {
return "You are trying to render a template, but we can't find the View Class";
}
}
}
如果這些項目不是常量,則需要引用它們。 –
@JayBlanchard你打敗了我,儘管如此,我還是會與空間合作(見「無肉肉」)?我懷疑它... – webeno
可能不是@webeno,但拋出的錯誤可能是因爲PHP試圖解釋一個不存在的常量。 –