PHP: how can a class reference its own name?

后端 未结 5 1926
小蘑菇
小蘑菇 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:06

    Well, there's get_class($Object)

    Then there's __CLASS__ when used within a class

    Or you could make a method that would return __CLASS__

提交回复
热议问题