在为抽象类定义命名空间时遇到问题。 类看起来像这样:
helloworld.class.php :
namespace Kitten;
abstract class HelloWorld {
public static function hi()
{
echo 'hello';
}
}
的index.php :
require_once helloworld.class.php;
Kitten::HelloWorld::hi();
我得到的错误是:syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM
任何有关正确方向的帮助或指示都将受到赞赏。 感谢。
答案 0 :(得分:3)
使用反斜杠字符
访问命名空间 \Kitten\HelloWorld::hi();
T_PAAMAYIM_NEKUDOTAYIM
表示双冒号::
,Scope Resolution Operator
您的require语句也不正确。将文件和路径用引号括起来,如下所示:
require_once 'helloworld.class.php';