Where and why do we use __toString() in PHP?

后端 未结 10 1655
星月不相逢
星月不相逢 2021-01-01 10:34

I understand how it works but why would we practically use this?



        
10条回答
  •  执笔经年
    2021-01-01 11:05

    Using __toString() overrides the operator that is called when you print objects of that class, so it makes it easier for you to configure how an object of that class should be displayed.

提交回复
热议问题