note 111738 added to function.print-r
| From: | preda dot vlad at yahoo dot com | Date: | Fri, 22 Mar 2013 09:40:45 +0000 |
| Subject: | note 111738 added to function.print-r | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-194173@lists.php.net to get a copy of this message | ||
print_r(), just like var_dump() does NOT cast an object, not even if it has a __toString() method -
which is normal.
<?php
class A {
public function __toString() {
return 'In class A';
}
}
$a = new A;
echo $a; // In class A
print_r($a); // A Object()
// you can simulate the echo by casting it manually
print_r((string)$a); // In class A
----
Server IP: 69.147.83.199
Probable Submitter: 188.229.32.1
----
Manual Page -- http://php.net/manual/en/function.print-r.php
Edit -- https://master.php.net/note/edit/111738
Del: integrated -- https://master.php.net/note/delete/111738/integrated
Del: useless -- https://master.php.net/note/delete/111738/useless
Del: bad code -- https://master.php.net/note/delete/111738/bad+code
Del: spam -- https://master.php.net/note/delete/111738/spam
Del: non-english -- https://master.php.net/note/delete/111738/non-english
Del: in docs -- https://master.php.net/note/delete/111738/in+docs
Del: other reasons-- https://master.php.net/note/delete/111738
Reject -- https://master.php.net/note/reject/111738
Search -- https://master.php.net/manage/user-notes.php