Re: Class question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
          }
}

on Friday 15 September 2006 11:01, Roger Helgesen wrote:
> I have 3 classes, CLASS A,B and C
>
> class A {
>           var $some_var;
>            var $class_B;
>           function A(){
>                 $this->class_B = new B();
>                 $this->some_var=2;
>           }
> }
>
> class B {
>           var $some_var;
>            var $class_C;
>           function B(){
>                 $this->class_C = new C();
>                 $this->some_var= some_var_from_class_A;
>           }
> }
>
> class C {
>           var $some_var;
>
>           function C(){
>                 $this->some_var= some_var_from_class_A;
>           }
> }
>
>
>
> How can class B and C get the value of $some_var_class_A without using
> "$this->class_B = new B($some_var);"
>
>
> roger helgesen

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux