On Wed, Mar 8, 2017 at 7:44 PM, Andrea Faulds <a...@ajf.me> wrote: > Fleshgrinder wrote: > >> On 3/8/2017 7:36 PM, Andrea Faulds wrote: >> >>> Hi, >>> >>> Andrey Andreev wrote: >>> >>>> The question is rather "is this value a string?", only with the added >>>> assumption that __toString() objects are treated as "string objects" >>>> and thus fulfill the condition (another reason why I went for an >>>> is_string() parameter). >>>> >>> >>> This is a faulty assumption. The presence of __toString() doesn't mean >>> the object is a string, or intended to be used like one. >>> >>> >> What is it then in your book? >> >> > It means the object can be converted to a string. But such a conversion > may entail a loss of information and not be equivalent to the object > itself. It might be a “human-readable” form, for instance. >
To give an example: Exceptions implement __toString(), which contains the exception message, location information and backtrace. Of course, exceptions are rather different from strings and treating an exceptions as a string is usually incorrect. Nikita