note 56228 added to language.oop5.abstract
| From: | ramonzamora at gmail dot com | Date: | Sat, 27 Aug 2005 22:46:32 +0000 |
| Subject: | note 56228 added to language.oop5.abstract | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94279@lists.php.net to get a copy of this message | ||
so abstract clases are the same than inheritance+interfaces??
<?php
//using inheritance+interfaces
interface callA{
protected function callA();
}
class callB{
protected $b;
protected function callB(){
return $this->b;
}
}
class caller extends callB implements callA{
protected $a;
public function __construct($a,$b){
$this->a=$a;
$this->b=$b;
}
protected function callA(){
return $this->a;
}
public function callAB(){
return $this->callA().$this->callB();
}
}
$caller=new caller('a','b');
$caller->callAB();
//using abstract class
abstract class callAB{
abstract protected function callA();
protected $b;
protected function callB(){
return $this->b;
}
}
class caller extends callAB{
protected $a;
public function __construct($a,$b){
$this->a=$a;
$this->b=$b;
}
protected function callA(){
return $this->a;
}
public function callAB(){
return $this->callA().$this->callB();
}
}
$caller=new caller('a','b');
$caller->callAB();
?>
the only difference i see is that using inheritance+interfaces you can instantiate the parent but
using abstract classes you can't
----
Manual Page -- http://www.php.net/manual/en/language.oop5.abstract.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56228
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56228&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56228&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56228&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56228&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56228&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56228&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56228&report=yes
Search -- http://master.php.net/manage/user-notes.php