I am new to OOP and am wondering if I can extend a class more than once to use the methods inside the class I want to extend, eg...
class one { function blah() {} }
class two extends one { this->blah(); }
class three extends one { this->blah(); }
Yes, you can extend a class into as many "children" as you need to. And you can extend each of those "children" as often as needed, etc.
<?php class Example { protected $name; protected function hello() { return "Hello, " . $this->name; } } class Foo extends Example { protected $name = "World"; public function test() { echo $this->hello(); } } class Bar extends Example { protected $name = "PHPBuilder"; public function test() { echo $this->hello(); } } $a = new Foo(); $a->test(); echo "<br>"; $b = new Bar(); $b->test();
Ah, thanks for the reply.