how can i save content of current webpage in word through php

浪尽此生 提交于 2020-01-06 19:25:13

问题


i need to save contents of webpage on word. i need to keep the links and formating too. if i send

$ter=$ter. "<a href='$url'>".$chunk."</a> ";
 $fp  =  fopen("test.doc",  'w+'); 
        $str  =  $ter;

        fwrite($fp,  $str); 

        fclose($fp);

i get a word document but i loose the links ..it comes out as

a href='http://www.google.com/search?q=sells+sea+shells%0D%0A'>sells sea shells


回答1:


Going along with this weird pretend ".doc" file which Word (2007) does seem to display as a document; if I change your fwrite line:

fwrite($fp,  '<html><body>' . $str . '</body></html>');

It works.




回答2:


You may wan't to read a related Question here at Stack Overflow. I think you will find a lot of useful information here:

Create Word Document using PHP in Linux



来源:https://stackoverflow.com/questions/4415729/how-can-i-save-content-of-current-webpage-in-word-through-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!