Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > #31766 : printf and __toString
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 8th March 02:10
php-bugs
External User
 
Posts: 1
Default #31766 : printf and __toString


From: Robin at RHarmsen dot nl
Operating system: Windows 2003
PHP version: 5.0.3
PHP Bug Type: Output Control
Bug description: printf and __toString

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 bug report at http://bugs.php.net/?id=31766&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31766&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31766&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31766&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31766&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31766&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31766&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31766&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31766&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31766&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31766&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=31766&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=31766&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31766&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31766&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31766&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31766&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31766&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31766&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31766&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31766&r=mysqlcfg
  Reply With Quote


  sponsored links


2 8th March 02:10
External User
 
Posts: 1
Default #31766 : printf and __toString


ID: 31766
Updated by: derick@php.net
Reported By: Robin at RHarmsen dot nl
-Status: Open
+Status: Bogus
Bug Type: Output Control
Operating System: Windows 2003
PHP Version: 5.0.3
New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the do***entation 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()


Previous Comments:
------------------------------------------------------------------------

[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
  Reply With Quote
3 8th March 02:10
php-bugs
External User
 
Posts: 1
Default #31766 : printf and __toString


ID: 31766
User updated by: Robin at RHarmsen dot nl
Reported By: Robin at RHarmsen dot nl
Status: Bogus
Bug Type: Output Control
Operating System: Windows 2003
PHP Version: 5.0.3
New Comment:

I thought it also applyd to printf and sprintf
to bad


Previous Comments:
------------------------------------------------------------------------

[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 do***entation 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
  Reply With Quote
4 8th March 02:10
External User
 
Posts: 1
Default #31766 : printf and __toString


ID: 31766
Updated by: helly@php.net
Reported By: Robin at RHarmsen dot nl
-Status: Bogus
+Status: Open
-Bug Type: Output Control
+Bug Type: Feature/Change Request
-Operating System: Windows 2003
+Operating System: *
PHP Version: 5.0.3
-Assigned To:
+Assigned To: Andi
New Comment:

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.


Previous Comments:
------------------------------------------------------------------------

[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 do***entation 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
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666