使用Trait,想要使用CONST,但这是不允许的,所以我试过静态

时间:2017-03-26 13:55:23

标签: php

尝试运行此代码:

trait Publishable {

    static $PUBLISH = 'publish';
    static $DRAFT = 'draft';
    static $SCHEDULE = 'schedule';

    static $STATUS = [
        $DRAFT => 0,
        $PUBLISH => 1,
        $SCHEDULE => 2
    ];

我得到了

'常量表达式包含无效操作'

我该怎么办?

0 个答案:

没有答案