Difference between ::class and get_class

后端 未结 3 2036
死守一世寂寞
死守一世寂寞 2021-01-11 19:38

Can you explain the difference between get_class($instance) and ClassName::class ?



        
3条回答
  •  旧时难觅i
    2021-01-11 20:22

    Another point is get_class takes instance as argument and ::class operate on Class definition directly without initializing any instance. You might want to get the class name without creating instance occasionally.

提交回复
热议问题