Maybe I'm wrong but I can remember that constructors cannot return anything. If you want to keep reference to object B inside the object A, you have to define a class A like this:
class a_object {
var $b_reference;
function a_object () {
$this->b_reference = new b_object();
}
}
$this is necessary because at end of the a_object contructor $b_reference will destroyed, in this way you reference a class variable that will be destroyed only when then object a_object is destroyed.
I hope this can be helpful...
Darryl wrote:
I have a class that works great under PHP4, but not under PHP3. I want to reference a method of an object instantiated by another object.
What am I doing wrong/is there a workaround:
class b_object {
function b_object() {
//whatever
}
function b_function() {
//whatever
}
}
class a_object {
var $b_reference;
function a_object() {
$b_reference = new b_object();
}
}
In my main routine, I want to be able to reference methods of b through a:
$a_reference = new a_object();
$a_reference->b_reference->b_function();
Thanks in advance
-Darryl