|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-08-11 08:48 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 04:00:02 2025 UTC |
Description: ------------ When using a echo/print with an object that has a __toString method defined it behaves strange depending on the usage. echo $obj is fine echo $obj."\n" is not Reproduce code: --------------- class TestClass { public $foo; public function __construct($foo) { $this->foo = $foo; } public function __toString() { return $this->foo; } } $n = new TestClass("test") ; echo $n ; // works - shows test echo $n."\n" ; // does not - show Object id #1 Expected result: ---------------- Test Actual result: -------------- Object id #1