Posted by Joe Scylla on 08/23/07 15:15
D_a_n_i_e_l wrote:
> how to declare a member of a class which is itself an object?
>
> class cA
> {
> private $blah;
> public function foo()
> {
> return $blah;
> }
> }
>
> class cB
> {
> private cA $a; // I want this to be of type class A
> }
>
<code>
class cB
{
private $a;
public function __construct()
{
$this->a = new cA();
}
}
$cb = new cB();
print_r($cb);
</code>
Returns:
cB Object
(
[a:private] =>
[cA] => cA Object
(
[blah:private] =>
)
)
Joe
[Back to original message]
|