Home > Backend Development > PHP Tutorial > PHP outputs the data as word and the img in the data can be displayed

PHP outputs the data as word and the img in the data can be displayed

不言
Release: 2023-03-23 13:02:02
Original
1516 people have browsed it

The content shared with you in this article is that php outputs data as word and the img in the data can be displayed. Friends in need can refer to it

$case_title1 =“abc”;
$content = "catwoe<span>implement<img src="http://www.baidu.com/04_20170109164233.jpg" alt="" /></span>"
$content = str_replace("src=\"/", "src=\"http://fangmingdesign.net/method/image/", $all_lists);//给是相对路径的图片加上域名变成绝对路径,导出来的word就会显示图片了   
			$filename = iconv(&#39;utf-8&#39;, &#39;gb2312&#39;, $case_title1);  
			header(&#39;pragma:public&#39;);  
			header(&#39;Content-type:application/vnd.ms-word;charset=utf-8;name="&#39;.$case_title1.&#39;".doc&#39;);  
			header("Content-Disposition:attachment;filename=$filename.doc");//attachment新窗口打印inline本窗口打印  
			$html = &#39;<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"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>&#39;;//这句不能少,否则不能识别图片  
			echo $html.$content.&#39;</html>&#39;;
Copy after login

Related recommendations:

PHP full site development engineer-Extended CSS animation, animate.css and wow.js


The above is the detailed content of PHP outputs the data as word and the img in the data can be displayed. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template