復(fù)制代碼 代碼如下:
 
abstract class postParent 
{ 
protected $querySQL; 
public $fetchResult; 
public $timeAgo; // eg : 2 days ago 
abstract protected function buildHTML(); 
public function getSQL() 
{ 
return $this->querySQL; 
} 
public function fetchResult( $result ) 
{ 
$this->fetchResult = mysql_fetch_assoc( $result ); 
} 
public function error() 
{} 
} 
class readArticle extends postParent 
{ 
public function __construct( $id ) 
{ 
$this->querySQL =<<<eof 
SELECT title, author, text, unixtime FROM post 
WHERE id = $id ORDER BY unixtime DESC; 
eof; 
} 
public function buildHTML() 
{ 
return <<<eof 
<div> 
<div> 
<h4> 
<a  
class="post-title-a" > {$this->fetchResult['title']} 
</a> 
</h4> 
</div> 
<div> 
<span>{$this->fetchResult['author']}</span> at 
<time>{$this->timeAgo}</time> 
</div> 
<div> 
{$this->fetchResult['text']} 
</div> 
</div> 
eof; 
} 
} 
新聞熱點(diǎn)
疑難解答