Objects Within Objects : Objects « Class « PHP






Objects Within Objects

 
<?
    class DogTag {
            public $Words;
    }

    class Dog {
            public $Name;
            public $DogTag;

            public function bark( ) {
                    print "Woof!\n";
            }
    }

    $poppy = new Poodle;
    $poppy->Name = "Poppy";
    $poppy->DogTag = new DogTag;
    $poppy->DogTag->Words = "call 555-1234";
?>
  
  








Related examples in the same category

1.Comparing Objects with == and ===
2.Create a new class and create an instance then use its property and method
3.Object Initialization
4.Object Overloading
5.Object Properties
6.Object Type Information
7.Creating a new object and assigning it to a variable