I´ve found the example below which took my attention.

The call to cCat::Miew() assumes the cDog context and
is able to access $this of cDog.

Is this supposed to be a bug or something that was not
expected ?????

It happens to PHP4 to and php5. And looks a bit
strange...


class cCat {
   function Miew(){
     // cCat does not have a member "kind", but cDog
has, and we'll use it
     echo "I am ".$this->kind.", and I say MIEW\n";

     // here things are even stranger: does cCat class
     // support WhoAmI function? guess again...
     $this->WhoAmI();
   }
  }

  class cDog {
   public $kind = "DOG";
   function Bark(){
       // let's make this dog act like a cat:)
       cCat::Miew();
   }

   function WhoAmI(){
     echo "Yes, I'm really ".$this->kind."!";
   }
  }

 $dog = new cDog();
  echo $dog->Bark();

//outputs:
//I am DOG, and I say MIEW
//Yes, I'm really DOG!


__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to