【发布时间】:2014-01-03 07:43:26
【问题描述】:
我有一个名为 Pages 的类用作命名空间,如下所示:
<?php
static class Pages
{
class Page
{
public $Name;
public $Title;
public function __construct($Name, $Title)
{
$this->Name = $Name;
$this->Title = $Title;
}
}
}
?>
其他地方:
<?php
$g_Pages = new Pages::Page("My Name", "My Title");
?>
很遗憾,我收到了 Parse 错误:语法错误,意外的“页面”(T_STRING),期望变量(T_VARIABLE)或“$”
我做错了什么?
【问题讨论】:
-
错误消息似乎与您发布的代码无关。
-
是的,对不起,我试图匿名化这个例子。原来的类名有不同的名字。我刚刚对其进行了编辑以修复。
标签: php namespaces nested-class