创建一个word.php文件,内容如下
	<?php 
	class word 
	{  
	function start() 
	{ 
	ob_start(); 
	print'<html xmlns:o="urn:schemas-microsoft-com:office:office" 
	xmlns:w="urn:schemas-microsoft-com:office:word" 
	xmlns="http://www.w3.org/TR/REC-html40">';
}
	function save($path) 
	{
	print "</html>"; 
	$data = ob_get_contents();
ob_end_clean();
	$this->wirtefile ($path,$data); 
	}
	function wirtefile ($fn,$data) 
	{
	$fp=fopen($fn,"wb"); 
	fwrite($fp,$data); 
	fclose($fp); 
	} 
	}
	?>
	在创建一个test.php页面,做个测试
	内容如下<?php 
	include("word.php"); 
	$word=new word;
	$word->start(); 
	?>
	在此写你要写入word的内容
	<? 
	$word->save("data.doc");//保存word并且结束.
echo '在此也要显示在页面上的内容<a href="data.doc" target=_blank>这里</a>';
	?>