note 2802 deleted from language.oop by vincent
| From: | vincent@php.net | Date: | Thu, 11 Sep 2003 19:48:45 +0000 |
| Subject: | note 2802 deleted from language.oop by vincent | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-56185@lists.php.net to get a copy of this message | ||
Note Submitter: immo@nospam.org
----
Here is some code to demonstrate member objects and inheritance.
class ParentObject {
var $value;
function ParentObject() {
$this->value = 42;
}
}
class MemberObject extends ParentObject {
var $string;
function MemberObject() {
$this->string = "This is a test string.";
$this->ParentObject();
}
}
class ObjTest {
var $ObjPointer;
function ObjTest() {
$tmp = new MemberObject;
$this->ObjPointer = $tmp;
}
}
echo "Creating object of type ObjTest...";
$object = new ObjTest;
echo "Done.<br>\n";
echo "String Contents: " . $object->ObjPointer->string . "<br>\n";
echo "Value Contents: " . $object->ObjPointer->value . "<br>\n";