Answer the question
In order to leave comments, you need to log in
Creating an object inside another class?
Question 1 - is the following option correct, if not, why not?
class A {
}
class B {
public $a;
function __construct() {
$this->a = new A();
}
}
class A {
}
class B {
public $a = new A();
}
Answer the question
In order to leave comments, you need to log in
It doesn't work like that, but PHP syntax seems to make sense.for
This declaration may include an initialization, but this initialization must be a constant value--that is, it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question