Questionable private $varname behavior

From: Date: Fri, 11 Jul 2003 23:27:14 +0000
Subject: Questionable private $varname behavior
Groups: php.internals 
Request: Send a blank email to internals+get-3370@lists.php.net to get a copy of this message
Hi, a discussion on php.general led to the discovery of this oddly legal script: <?php class dog {
    // declare two private variables
    private $Name;
    private $DogTag;
    public function bark() {
      print "Woof!\n";
    }
    public function printName() {
      print $this->Name; // prints nothing!
    }
} // new class, for testing derived stuff class poodle extends dog {
    public function bark() {
      print "Yip!\n";
    }
} // I now create an instance of the // derived class $poppy = new poodle; // and set its private property $poppy->Name = "Poppy"; print $poppy->Name. "\n"; $poppy->printName(); print_r($poppy); ?> outputs: Poppy poodle Object (
    [Name:private] =>
    [DogTag:private] =>
    [Name] => Poppy
) Is this expected behavior or should I open a bug? Greg

« previous php.internals (#3370) next »