M
M
Maria2016-12-19 20:15:28
PHP
Maria, 2016-12-19 20:15:28

PHP. OOP. How to implement combination, association and inheritance between classes?

I understand the implementation of relations between classes, please tell me with an example how to implement relations according to this scheme 285ea28b8734461dbd8299bcde4921a2.png
. If it’s not difficult, please write the code for clarity, here are my attempts to implement a combination between class A and B:

class A 
{
    function __construct()
    {
        
    }
}

class B
{
    public $objectA;
    function __construct()
    {
        $this->objectA = new A();
    }
}

ps: In what order will constructors be called when creating an object $f1 = new F();?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dmitriy, 2016-12-19
@dmitriylanets

here everything is detailed larin.in/archives/26

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question