#37702 [Csd->Opn]: Make toString working with strval
| From: | derick@php.net | Date: | Mon, 05 Jun 2006 20:34:35 +0000 |
| Subject: | #37702 [Csd->Opn]: Make toString working with strval | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969373180@lists.php.net to get a copy of this message | ||
ID: 37702
Updated by: derick@php.net
Reported By: php at bouchery dot com
-Status: Closed
+Status: Open
-Bug Type: Feature/Change Request
+Bug Type: Documentation problem
Operating System: *
PHP Version: 5.1.*
Assigned To: helly
New Comment:
Opening this as a doc problem then, as it needs to be documented that
it will work in 5.2 ofcourse.
Previous Comments:
------------------------------------------------------------------------
[2006-06-05 18:46:15] php at bouchery dot com
It's a bug ?
Seen in the documentation :
"It is worth noting that the __toString method will only be called when
it is directly combined with echo() or print()."
And Example 19-28 confirm this "feature".
here : http://www.php.net/manual/en/language.oop5.magic.php
------------------------------------------------------------------------
[2006-06-05 15:34:28] helly@php.net
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.
Cannot be fixed in 5.1 and is already fixed in HEAD and 5.2
------------------------------------------------------------------------
[2006-06-05 15:29:08] php at bouchery dot com
Description:
------------
Currently, __toString work ONLY with echo/print, and it's very
restrictive.
It could be very interresting to allow toString working with strval()
to avoid this :
<?php
if( is_object($var) ) $text = 'var = ' . $var->__toString();
else $text = 'var = ' . $var;
?>
Expected result:
----------------
<?php
$text = 'var = ' . strval($var);
?>
Or better :
<?php
$text = 'var = ' . $var;
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37702&edit=1