The Word document generated by PHP can be seen frequently in learning, and this article will introduce a method.
PHP generates Word documents, there are many methods on the web, there are calls to COM components generated by the installation of PHP extensions generated, there are also references to third-party class libraries, such as Phpword generated. The following are the most concise two methods, no need to install the other, as long as you install the PHP environment can be directly generated.
<?phpheader ("Content-type:text/html;charset=utf-8");/**
* @desc method One, generate Word documents
* @param $content * @param string $fileName */function createword ($content = ', $fileName = ' New_file.doc ') { if (empty ( $content)) { return; } $content = '
* @desc Method II, Generate Word documents and download
* @param $content * @param string $fileName */function Downloadword ($content, $fileName = ' New_file.doc ') {if (Empty ($cont ENT)) {return; } header ("Cache-control:no-cache, must-revalidate"); Header ("Pragma:no-cache"); Header ("Content-type:application/octet-stream"); Header ("content-disposition:attachment; Filename= $fileName "); $html = '
After running the
PHP generates Word documents
PHP generates Word documents
This article describes how PHP generates Word documents, and more about the PHP Chinese web.