Hi,

As an observer of this whole debate, I'd like to point out that if __toString() will be magical anywhere, it must be magical everywhere PHP would normally do an implicit cast, otherwise it does nothing but confuse the issue. implicit cast to string always happens when using string operators and echo/print, and so the __toString() should be looked for. As for built in functions, it would be logical to expect those that operate on strings to do an implicit cast. The only question that I think should be addressed is whether it is practical in terms of performance and code structure.

If this seems like too much magic, the entire feature should be dropped, imo (I hope not - I like the __toString() feature, it will be great for many applications).

Greg

Adam Maccabee Trachtenberg wrote:
This is needed for SimpleXML. It's an object pretending to be a set of
strings. You've got to be able to things like:

htmlentities($xml->element);

You can't do that currently because htmlentities() complains that
you're passing in an object.

As far as I'm concerned, if you don't want your object to be
auomatically cast to a string, you shouldn't provide a __toString()
method.

-adam


-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to