Re: __toString() with cast is broken in php5 RC1
| From: | David Giffin | Date: | Fri, 02 Apr 2004 00:03:38 +0000 |
| Subject: | Re: __toString() with cast is broken in php5 RC1 | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-8882@lists.php.net to get a copy of this message | ||
Hi Marcus,
Is this going to change back? The php5 documentation on the zend site
shows that both casting and print/echo should work.
I guess people could use the output buffering methods to get the print
data for the time being. A not so happy work around :(
Thanks again,
David
On Fri, 2 Apr 2004, Marcus Boerger wrote:
> Hello David,
>
> that's correct. See the NEWS file, 3rd entry:
>
> 18 March 2004, PHP 5 Release Candidate 1
> - Fixed numerous bugs with the just-in-time auto-global initialization, that
> could cause $_SERVER, $argv/$argc and other variables not to work properly.
> (Zeev)
> - Fixed data corruption with constant assignments to object properties. (Zeev)
> - Changed __toString() to be called automatically only with print and echo
> statements. (Andi)
>
> Friday, April 2, 2004, 1:13:28 AM, you wrote:
>
>
> > Hi There,
>
> > I just got a chance tp update to PHP5 RC1 and noticed that some things
> > have changed for the __toString method. It seems that it it only getting
> > called when the object is printed or echo. Casting the object to a string
> > returns the Object #. Here is an example:
>
>
>
> > ---- The Script:
>
> > <?php
>
> > class obj
> > {
> > function __toString()
> > {
> > return "yo!!\n";
> > }
> > }
>
> > $obj = new obj();
> > print_r($obj);
>
> > $test = (string) $obj;
>
> > print $test;
> > print $obj;
>
> ?>>
>
> > ----- Produces:
>
> > obj Object
> > (
> > )
> > Object id #1yo!!
>
>
>
> > Thanks,
> > David
>
>
>
>
> --
> Best regards,
> Marcus mailto:helly@php.net
>