2009/4/19 Alex S Kurilo aka Kamazee <me@xxxxxxxxxxxx>: > Is it right that 'self' in inherited method still points to the parent? > If it is, can you explain it? It makes me worry :) > > A piece of code below for example > > <?php > class MyParent { > const NAME = 'MyParent'; > public function get_instance() { > return new self; > } > public function get_another_instance() { > $class_name = get_class($this); > return new $class_name; > } > public function get_name() { > return self::NAME; > } > } > > class MyClass extends MyParent { > const NAME = 'MyClass'; > } > > $a = new MyClass; > $b = $a->get_instance(); > $c = $a->get_another_instance(); > > echo $a->get_name(),"\n"; > echo get_class($b),"\n"; > echo get_class($c),"\n"; > ?> Up until 5.3 this was just the way it was. It has been "fixed" in 5.3. See here for more info: http://php.net/lsb -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php