How to access constant defined in child class from parent class functions?

后端 未结 5 1579
时光说笑
时光说笑 2021-02-03 18:37

I saw this example from php.net:



        
5条回答
  •  后悔当初
    2021-02-03 18:53

    Instead of

    $c = get_class( $this );
    echo $c::MY_CONST;
    

    Do this

    $c = get_class( $this );
    echo constant($c . '::MY_CONST');
    

提交回复
热议问题