function created_word(){
	$str_html = return_html();
	$path = 'folder/'.date('Y-m-d');
    $file_name = $path.'/'.date('H-i-s').'__'.time().'.doc';
    if(!file_exists($path)){
        mkdir($path);
        chmod($path,0777);
    }
    $result = file_put_contents($file_name,$str_html);
}
function return_html(){
	$str_html = '<html xmlns:v="urn:schemas-microsoft-com:vml"
	        xmlns:o="urn:schemas-microsoft-com:office:office"
	        xmlns:w="urn:schemas-microsoft-com:office:word"
	        xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"=
	        xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head>';
	$str_html.='<h2 style="text-align: center;">内容</h2>';
	$str_html.='</html>';
	return $str_html;
}
  
一般不插入html标签和head标签直接插入html的代码会导致微软软件打不开,不会自动识别内容是html格式的。用WPS可以打开,加上这个html后就可以直接用微软打开了。  觉得有用或者解决你的问题了就点个赞留个言,虽然我也不经常来看,哈哈 
                
                
                
        
        
    
 
 |