Re: Exception::__toString() not called

From: Date: Wed, 17 Mar 2004 16:16:18 +0000
Subject: Re: Exception::__toString() not called
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-8565@lists.php.net to get a copy of this message
Hi - Andi Gutmans wrote:
Just to clarify, this is only for internal classes like Exception, right? Userland __toString() will continue to be invoked when an explicit (string) cast (or concat, etc.) is used, correct?
Wrong. The only time userland __toString() will be invoked will be in print/eval. We found that all the places where this happened automaticall were buggy due to the way our opcode mechanism works. It's not a quick fix to support this and is not something I would like to do before 5.0.0. You're going to have to explicitly call __toString() in anything except for print/eval.
Ugh ... that really sucks. I understand there's a good reason & don't understand the internals, but I would say that as a user being able to work transparently with objects or strings (i.e. the behavior in b2-b4) was *extremely* nice. Anyway, thanks for clarification. Hans

« previous php.internals (#8565) next »