Check out Scrivo

Do you want to try out Scrivo? Then here's a demo for you that does not just get your feet wet but lets you plunge right in.

Contact us

For more information, please contact us. We're happy to help you out!

Next Oct 15 Previous

I've got the object on a string.

Arbitrary objects can be cast to strings or used in functions like echo (whoops, language construct) or substr(), but these objects need to implement a magic function first. Which one is this:

A: __get()
B: __toString()
C: __invoke()
D: __to_string()


The __toString() function of an object will be called to convert an object to a string if you try to use an object where a string is expected so answer B is correct.

Note that is not spelled __to_string() as answer D suggest despite there's a magic function named __set_state() too. If you understand PHP naming schemes please explain them to me.