Not got my thinking cap on today, PHP class Question.

Associate
Joined
26 Jun 2003
Posts
1,140
Location
North West
I have a class which initialses two classes inside its constructor, but each of these classess needs to access functions from each other.

Heres an example:

say class3 needs to use function1 in class2.

PHP:
require_once('MyClass2.php');
require_once('MyClass3.php');

class MyClass1
{

  var $class2;
  var $class3;

  function MyClass1()
  { 

    $this->class2 = new MyClass2();
    $this->class3 = new MyClass3();

  } 

}

I know I could pass each class in the constructor but is there another method that I am missing?

Thx
 
Back
Top Bottom