Hey there,

I have a class A that uses class B. Class B also uses class A. This is recursive and am wondering if you can redefine PHP classes like in C++.

class A{}

class B{
    private $classA;

    public function __construct($classA){
       $this->classA = $classA;
    }

    public function someFunc(){ echo 'blah'; }
}

class A{
    private $classB;

    public function __construct($classB){
        $classB->someFunc();
    }
}

Why not just try it and find out. That's one of the great things with having xampp or wamp/lamp. Because you can easily test it under a localhost environment with that software and I can tell you now, testing that won't crash a your computer unlike calculating pi to 1,000,000 digits using the bcmath library.

commented: Good advice ;) +22
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.