note 68794 added to function.sprintf
| From: | bknakkerNO at SPAMgmail dot com | Date: | Thu, 10 Aug 2006 21:54:20 +0000 |
| Subject: | note 68794 added to function.sprintf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115777@lists.php.net to get a copy of this message | ||
Note that in PHP5 (.1.4 for me) sprintf will not use the __toString function of an object.
<?php
class pr{
private $l;
public function __construct($l)
{
$this->l=$l;
}
public function __toString()
{
return $this->l;
}
}
echo new pr('This works!!'); //This will display 'This works!!'
echo sprintf(new pr('This doesnt')); // will display 'Object'
?>
Be careful with that!
----
Server IP: 195.70.37.52
Probable Submitter: 62.68.181.110
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.sprintf.php
Edit -- https://master.php.net/note/edit/68794
Del: integrated -- https://master.php.net/note/delete/68794/integrated
Del: useless -- https://master.php.net/note/delete/68794/useless
Del: bad code -- https://master.php.net/note/delete/68794/bad+code
Del: spam -- https://master.php.net/note/delete/68794/spam
Del: non-english -- https://master.php.net/note/delete/68794/non-english
Del: in docs -- https://master.php.net/note/delete/68794/in+docs
Del: other reasons-- https://master.php.net/note/delete/68794
Reject -- https://master.php.net/note/reject/68794
Search -- https://master.php.net/manage/user-notes.php