note 35633 added to ref.classobj
| From: | mark at g33kz dot co dot uk | Date: | Tue, 09 Sep 2003 10:03:42 +0000 |
| Subject: | note 35633 added to ref.classobj | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-55874@lists.php.net to get a copy of this message | ||
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 ---
----
Manual Page -- http://www.php.net/manual/en/ref.classobj.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35633
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35633&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35633&report=yes