note 40399 modified in keyword.extends by danbrown

From: Date: Wed, 17 Jun 2009 19:04:36 +0000
Subject: note 40399 modified in keyword.extends by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-157027@lists.php.net to get a copy of this message
It is possible to override a method innherited from a parent class by simply re-defining the method (for those of us who enjoy using abstract classes). <?php class A { var $foo; function A() { $this->foo = "asdf"; } function bar() { echo $this->foo." : Running in A"; } } class B extends A { function bar() { echo $this->foo." : Running in B"; } } $myClass = new B; $myClass->bar(); ?> --was-- It is possible to override a method innherited from a parent class by simply re-defining the method (for those of us who enjoy using abstract classes). <? class A { var $foo; function A() { $this->foo = "asdf"; } function bar() { echo $this->foo." : Running in A"; } } class B extends A { function bar() { echo $this->foo." : Running in B"; } } $myClass = new B; $myClass->bar(); ?> http://php.net/manual/en/keyword.extends.php

« previous php.notes (#157027) next »