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

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

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



        
10条回答
  •  旧巷少年郎
    2021-01-01 10:54

    You don't have to specifically call the toString method. When ever you print the object toString is being called implicitly. Any other method would have to be called explicitly.

提交回复
热议问题