📜  trait 类有 consttoctor - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:06.282000             🧑  作者: Mango

代码示例1
trait HasPluginInfoTrait{
    public function __construct() { 

        $this->plugin_name        = PLUGIN_NAME;
        $this->version            = PLUGIN_VERSION;

        if ( method_exists( $this, 'init' ){
            $this->init();
        }
    }
}

class SampleClass {
    use HasPluginInfoTrait;

    private function init(){
        // Code specific to SampleClass
    }
}