note 35633 rejected from ref.classobj by didou
| From: | didou@php.net | Date: | Mon, 01 Mar 2004 11:53:42 +0000 |
| Subject: | note 35633 rejected from ref.classobj by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-66037@lists.php.net to get a copy of this message | ||
Note Submitter: mark@g33kz.co.uk
----
There's an odd quirk with multilevel objects in PHP:
<?PHP
class foo {
var $str;
function foo () {
$this->str = 'something';
}
}
class bar {
var $obj;
function bar () {
$this->obj = new foo ();
}
}
$myObj = new bar ();
echo ('--- '.$myObj->obj->str.' ---');
echo ("\\n");
echo ("--- $myObj->obj->str ---");
?>
You would expect this to output:
--- something ---
--- something ---
but instead it outputs:
--- something ---
--- Object->str ---