note 70257 added to function.strval
| From: | judas dot iscariote at gmail dot com | Date: | Mon, 09 Oct 2006 04:02:44 +0000 |
| Subject: | note 70257 added to function.strval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-118232@lists.php.net to get a copy of this message | ||
since PHP 5.2 this function can be used with objects that implements the magic __toString() method,
previous versions will return the object id as an string.
<?php
class test {
function __toString()
{
return "foo";
}
}
$foo = strval(new test) . PHP_EOL;
echo $foo;
?>
php 5.2 outputs : foo
earlier versions : Object id #1
----
Server IP: 200.24.234.70
Probable Submitter: 200.7.26.129
----
Manual Page -- http://www.php.net/manual/en/function.strval.php
Edit -- https://master.php.net/note/edit/70257
Del: integrated -- https://master.php.net/note/delete/70257/integrated
Del: useless -- https://master.php.net/note/delete/70257/useless
Del: bad code -- https://master.php.net/note/delete/70257/bad+code
Del: spam -- https://master.php.net/note/delete/70257/spam
Del: non-english -- https://master.php.net/note/delete/70257/non-english
Del: in docs -- https://master.php.net/note/delete/70257/in+docs
Del: other reasons-- https://master.php.net/note/delete/70257
Reject -- https://master.php.net/note/reject/70257
Search -- https://master.php.net/manage/user-notes.php