note 68794 deleted from function.sprintf by cmb
| From: | cmb@php.net | Date: | Sun, 14 Jul 2019 11:19:23 +0000 |
| Subject: | note 68794 deleted from function.sprintf by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211563@lists.php.net to get a copy of this message | ||
Note Submitter: bknakkerNO at SPAMgmail dot com
----
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!