note 94034 modified in language.oop5.abstract by danbrown
| From: | danbrown@php.net | Date: | Tue, 13 Oct 2009 15:42:45 +0000 |
| Subject: | note 94034 modified in language.oop5.abstract by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-161686@lists.php.net to get a copy of this message | ||
One fairly important difference between php's abstract functions and, say, Java, is that php
does not specify the return type in any way - or indeed whether there has to be one.
<?php public abstract function square($number); ?>
could be implemented by...
<?php
public function square($number) {
return $number*$number;
}
?>
or
<?php
public function square($number) {
print ($number*$number);
}
?>
So you need to take care that incompatibilities don't arise due to not returning the right kind
of value and this is not enforced in any way.
--was--
One fairly important difference between php's abstract functions and, say, Java, is that php
does not specify the return type in any way - or indeed whether there has to be one.
public abstract function square($number);
could be implemented by...
public function square($number) {
return $number*$number;
}
or
public function square($number) {
print ($number*$number);
}
So you need to take care that incompatibilities don't arise due to not returning the right kind
of value and this is not enforced in any way.
http://php.net/manual/en/language.oop5.abstract.php