PHP: how can a class reference its own name?

后端 未结 5 1890
小蘑菇
小蘑菇 2020-12-31 09:27

In PHP, how can a class reference its own name?

For example, what would the method look like to do this?

Dog::sayOwnClassName();
//echos \"Dog\";
         


        
5条回答
  •  有刺的猬
    2020-12-31 10:04

    public function sayClassName()
    {
        echo get_class($this);
    }
    

    get_class() php docs

提交回复
热议问题