PHP 中的简单 RTF 文件


simple rtf file in php

谁能帮我用php创建简单的.rtf文件?例如:我有一个页面:

<table>
<tr><td>ID</td><tr><td>sth</td></tr>
<tr><td>1</td><tr><td>sth1</td></tr>
<tr><td>1</td><tr><td>sth1</td></tr>
<tr><td>1</td><tr><td>sth1</td></tr>
</table>

我想使用此表创建一个.rtf文件,以允许用户使用MS Word等程序对其进行编辑。我正在尝试这样做:http://books.msspace.net/mirrorbooks/php5/067232511X/ch28lev1sec1.html 但它对我没有帮助。

//$rtf保存完整的文件数据

将文件保存在您的服务器上 1st

file_put_contents('/path/to/outfile.rtf', $rtf);

然后提供下载

header("Content-type: application/rtf");
echo file_get_contents("/path/to/outfile.rtf");
exit();