本篇文章给大家分享的内容是php把数据输出为word并且数据中的img可显示 ,有需要的朋友可以参考一下

$case_title1 =“abc”; $content = "catwoe<span>implement<img src="" alt="" /></span>" $content = str_replace("src=\"/", "src=\"", $all_lists);//给是相对路径的图片加上域名变成绝对路径,导出来的word就会显示图片了 $filename = iconv('utf-8', 'gb2312', $case_title1); header('pragma:public'); header('Content-type:application/vnd.ms-word;charset=utf-8;name="'.$case_title1.'".doc'); header("Content-Disposition:attachment;filename=$filename.doc");//attachment新窗口打印inline本窗口打印 $html = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns=""><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>';//这句不能少,否则不能识别图片 echo $html.$content.'</html>';

相关推荐: