html转word

<?php
$html = '	<table border="1">
		<tr><td>你好</td><td>你好</td><td>你好</td><td>你好</td><td><img src="http://topic.test.qfclou.com/upload/organization/logo/20190404/dee53b39335f4a35459f25517f358703.jpg" alt=""></td></tr>
		{{list}}
	</table>';
ob_start();
echo '<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"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><xml><w:WordDocument><w:View>Print</w:View></xml></head><body>'.$html.'</body></html>';
$data = ob_get_contents();
ob_end_clean();
file_put_contents('test.doc', $data);
flush();
?>

 

上一篇:PHP获取远程文件的大小,通过ob_get_contents实现


下一篇:php实现静态页面 buffer 缓冲区