}
}
$mht
->AddContents("tmp.html",
$mht
->GetMimeType("tmp.html"),
$content
);
for
(
$i
=0;
$i
<
count
(
$images
);
$i
++)
{
$image
=
$images
[
$i
];
if
( @
fopen
(
$image
, 'r') )
{
$imgcontent
= @
file_get_contents
(
$image
);
if
(
$content
)
$mht
->AddContents(
$files
[
$i
],
$mht
->GetMimeType(
$image
),
$imgcontent
);
}
else
{
echo
"file:".
$image
." not exist!<br />";
}
}
return
$mht
->GetFile();
}
使用方法:
代码如下
:
$fileContent
= getWordDocument(
$content
,"
http://php.yl1001.com
");
$fp
=
fopen
("test.doc", 'w');
fwrite(
$fp
,
$fileContent
);
fclose(
$fp
);
其中,
$content
变量应该是
HTML 源代码,后面的链接应该是能填补 HTML 代码中图片相
对路径的
URL 地址
注意,在使用这个函数之前,您需要先包含类
MhtFileMaker,这个类可以帮助我们生成
Mht 文档。
代码如下
:
<?php
/***********************************************************************
Class: Mht File Maker
Version: 1.2 beta
Author: Wudi <wudicgi@yahoo.de>
Description: The class can make .mht file.
***********************************************************************/
class
MhtFileMaker{
var
$config
=
array
();