Re: __toString()

From: Date: Mon, 15 Dec 2003 13:13:15 +0000
Subject: Re: __toString()
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-6469@lists.php.net to get a copy of this message
Derick Rethans wrote:
Why print and no echo? ;-) (Or was it the same again...)
I hope print and echo will be treated the same. It looks like right now __toString() is never called automatically, I just updated from CVS and I get "Object id #1" for the example program. BTW: The example in Zend/ZEND_CHANGES is outdated:
      Example:
        <?php
            class Foo {
                function __toString() {
                    return "What ever";
                ^^^ a "}" is missing
            }
            $obj = Foo;
                   ^^^ should be "new Foo"
            $str = (string) $obj; // call __toString()
            ^^^ This line should be removed I guess
            echo $obj; // call __toString()
            ^^^ should mention print too I guess
        ?>
Regards, - Chris

« previous php.internals (#6469) next »