Re: Class question
| From: | Andrei | Date: | Fri, 15 Sep 2006 09:18:26 +0000 |
| Subject: | Re: Class question | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-241814@lists.php.net to get a copy of this message | ||
Well in this example it will get to an infinite loop, but anyway like
Thomas said you must check into extending classes.
Andy
Thomas Munz wrote:
> Use 'extends' syntax for sub classes
>
> class A {
> var $some_var;
> var $class_B;
> function A(){
> $this->class_B = new B();
> $this->some_var=2;
> }
> }
>
> class B extends A {
> var $class_C;
> function B(){
> $this->A();
> $this->class_C = new C();
> // $this->some_var= some_var_from_class_A; <-- $this->some_var
> contains the value allready
> }
> }
>
> class C extends A {
> function C(){
> $this->A();
> // $this->some_var= some_var_from_class_A; <-- $this->some_var
> contains the value allready
> }
> }
>