#31766 [Opn->Csd]: printf and __toString

From: Date: Sun, 21 May 2006 05:30:28 +0000
Subject: #31766 [Opn->Csd]: printf and __toString
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-97419@lists.php.net to get a copy of this message
ID: 31766 Updated by: mfischer@php.net Reported By: Robin at RHarmsen dot nl -Status: Open +Status: Closed Bug Type: Feature/Change Request Operating System: * PHP Version: 5.0.3 Assigned To: Andi New Comment: This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2005-01-30 22:56:50] helly@php.net Actually this is a valid feature request and we said that we try to include this functionality in 5.1 once the inherent engine problems are solved. ------------------------------------------------------------------------ [2005-01-30 21:21:59] Robin at RHarmsen dot nl I thought it also applyd to printf and sprintf to bad :( ------------------------------------------------------------------------ [2005-01-30 21:07:43] derick@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php only echo and print call __toString() ------------------------------------------------------------------------ [2005-01-30 20:57:46] Robin at RHarmsen dot nl Description: ------------ When having an object with an __toString() and using this object as a parameter in a printf the __toString isn't called Reproduce code: --------------- class User { public $username; public function __toString() { return $username; } } $user = new User(); $user->username = "Test"; echo $this->user; printf("Logged in as: %s\n",$this->user); Expected result: ---------------- Test Logged in as: Test Actual result: -------------- Test Logged in as: Object id #1 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31766&edit=1

« previous php.bugs (#97419) next »