0
我正在尝试为我的某个网站制作一个调试类,类似于Java中的记录器类。在PHP中使用常量的语法错误
<?php
abstract class DebugLevel
{
const Notice = 1;
const Info = 2;
const Warning = 4;
const Fatal = 8;
}
class Debug
{
private static $level = DebugLevel::Fatal | DebugLevel::Warning | DebugLevel::Info | DebugLevel::Notice;
}
?>
我得到一个Parse error
:
Parse error: syntax error, unexpected '|', expecting ',' or ';' in (script path) on line 13
有什么不对?
所以,我该怎么做我想要做什么? –
@RiccardoBestetti:使用'__construct()'函数。我们不喜欢这里的勺子喂食器。使用'__construct()'非常简单。 –
当我发布评论时,他还没有写过使用'__construct()'。 –