PHP中abstract类中有abstract方法是否最先执行abstract方法,然后才执行其他方法?
rt
<br /> abstract class Node {<br /> private $debugMessages;<br /> <br /> public function __construct() {<br /> $this->debugMessages = array();<br /> $this->debug(__CLASS__.' constructor called.');<br /> }<br /> <br /> public function __destruct() {<br /> $this->debug(__CLASS__.' destructor called.');<br /> $this->dumpDebug();<br /> }<br /> <br /> protected function debug($msg) {<br /> $this->debugMessages[] = $msg;<br /> }<br /> <br /> private function dumpDebug() {<br /> echo implode('<br />', $this->debugMessages);<br /> }<br /> <br /> public abstract function getView();<br /> }<br /> <br /> <br /> class ForumTopic extends Node {<br /> private $debugMessages;<br /> <br /> public function __construct() {<br /> parent::__construct();<br /> $this->debug(__CLASS__.' constructor called.');<br /> }<br /> <br /> public function __destruct() {<br /> $this->debug(__CLASS__.' destructor called.');<br /> parent::__destruct();<br /> }<br /> <br /> public function getView() {<br /> return 'This is a view into '.__CLASS__.'<br />';<br /> }<br /> }<br /> <br /> $forum = new ForumTopic();<br /> echo $forum->getView();<br />